mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-03-21 19:23:41 +00:00
* Unit Test rework & Master/Ticker update * Fixes and working unit testing * Fixes * Test fixes and FA update * Fixed runtimes * Radio subsystem * move that glob wherever later * ident * CIBUILDING compile option * Fixed runtimes * Some changes to the workflow * CI Split * More split * Pathing * Linters and Annotators * ci dir fix * Missing undef fixed * Enable grep checks * More test conversions * More split * Correct file * Removes unneeded inputs * oop * More dependency changes * More conversions * Conversion fixes * Fixes * Some assert fixes * Corrects start gate * Converted some README.dms to README.mds * Removes duplicate proc * Removes unused defines * Example configs * fix dll access viol by double calling * Post-rebase fixes * Cleans up names global list * Undef restart counter * More code/game/ cleanup * Statpanel update * Skybox * add * Fix ticker * Roundend fix * Persistence dependency update * Reordering * Reordering * Reordering * Initstage fix * . * . * Reorder * Reorder * Circle * Mobs * Air * Test fix * CI Script Fix * Configs * More ticker stuff * This is now in 'reboot world' * Restart world announcements * no glob in PreInit * to define * Update * Removed old include * Make this file normal again * moved * test * shared unit testing objects * Updates batched_spritesheets and universal_icon * . * job data debug * rm that * init order * show us * . * i wonder * . * . * urg * do we not have a job ID? * . * rm sleep for now * updated rust-g linux binaries * binaries update 2 * binaries update 3 * testing something * change that * test something * . * . * . * locavar * test * move that * . * debug * don't run this test * strack trace it * cleaner * . * . * cras again * also comment this out * return to official rust g * Update robot_icons.dm * monitor the generation * . --------- Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
51 lines
2.5 KiB
Plaintext
51 lines
2.5 KiB
Plaintext
/// converted unit test, maybe should be fully refactored
|
|
|
|
/// Test that inserts and retrieves data from an sqlite database
|
|
/datum/unit_test/sqlite_tests_insert
|
|
|
|
/datum/unit_test/sqlite_tests_insert/Run()
|
|
// Arrange.
|
|
fdel("data/sqlite/testing_sqlite_tests_insert.db") // In case any remain from a previous local test, so we can have a clean new database.
|
|
var/database/stub_sqlite_db = new("data/sqlite/testing_sqlite_tests_insert.db") // Unfortunately, byond doesn't like having working sqlite stuff w/o a file existing.
|
|
SSsqlite.init_schema(stub_sqlite_db)
|
|
|
|
var/test_author = "alice"
|
|
var/test_topic = "Test"
|
|
var/test_content = "Bob is lame."
|
|
|
|
// Act.
|
|
SSsqlite.insert_feedback(author = test_author, topic = test_topic, content = test_content, sqlite_object = stub_sqlite_db)
|
|
var/database/query/Q = new("SELECT * FROM [SQLITE_TABLE_FEEDBACK]")
|
|
Q.Execute(stub_sqlite_db)
|
|
SSsqlite.sqlite_check_for_errors(Q, "Sqlite Insert Unit Test")
|
|
Q.NextRow()
|
|
|
|
// Assert.
|
|
var/list/row_data = Q.GetRowData()
|
|
if(!(row_data[SQLITE_FEEDBACK_COLUMN_AUTHOR] == test_author && row_data[SQLITE_FEEDBACK_COLUMN_TOPIC] == test_topic && row_data[SQLITE_FEEDBACK_COLUMN_CONTENT] == test_content))
|
|
TEST_FAIL("Data insert and loading failed to have matching information.")
|
|
|
|
/// Test that does a cooldown in a sqlite database
|
|
/datum/unit_test/sqlite_tests_cooldown
|
|
|
|
/datum/unit_test/sqlite_tests_cooldown/Run()
|
|
// Arrange.
|
|
fdel("data/sqlite/testing_sqlite_tests_cooldown.db") // In case any remain from a previous local test, so we can have a clean new database.
|
|
var/database/stub_sqlite_db = new("data/sqlite/testing_sqlite_tests_cooldown.db") // Unfortunately, byond doesn't like having working sqlite stuff w/o a file existing.
|
|
SSsqlite.init_schema(stub_sqlite_db)
|
|
|
|
var/days_to_wait = 1
|
|
|
|
// Act.
|
|
SSsqlite.insert_feedback(author = "Alice", topic = "Testing", content = "This is a test.", sqlite_object = stub_sqlite_db)
|
|
|
|
var/alice_cooldown_block = SSsqlite.get_feedback_cooldown("Alice", days_to_wait, stub_sqlite_db)
|
|
var/bob_cooldown = SSsqlite.get_feedback_cooldown("Bob", days_to_wait, stub_sqlite_db)
|
|
days_to_wait = 0
|
|
var/alice_cooldown_allow = SSsqlite.get_feedback_cooldown("Alice", days_to_wait, stub_sqlite_db)
|
|
|
|
// Assert.
|
|
TEST_ASSERT(alice_cooldown_block > 0, "User 'Alice' did not receive a cooldown, when they were supposed to.")
|
|
TEST_ASSERT(bob_cooldown <= 0, "User 'Bob' did receive a cooldown, when they did not do anything.")
|
|
TEST_ASSERT(alice_cooldown_allow <= 0, "User 'Alice' did receive a cooldown, when no cooldown is supposed to be enforced.")
|