mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-20 15:12:19 +00:00
* Adds drone tasks to Execute UTs on Aurora and Exodus * Adds a drone task to Migrate SQL and Perform the SQL UT on Runtime * Changes the SQL UT to respect the config.sql_enabled setting and use that sql connection * Changes the default config.sql_enabled state to 0, so uncommenting SQL_ENABLED has a actual effect * Moves a number of UT tests into a helper script (code_check.sh) * Updates the way the RUST_G dll/so is located * Adds a check to load_databases to verify that sql is enabled * Adds a check to establish_db_connection to verify that sql is enabled * Adds spearate config files used during the UTs (which hold the UT db connection info and enable/disable the db epending on the UT)
138 lines
4.1 KiB
Plaintext
138 lines
4.1 KiB
Plaintext
/datum/unit_test/sql_preferences_columns
|
|
name = "SQL: Preferences Columns"
|
|
|
|
/datum/unit_test/sql_preferences_columns/start_test()
|
|
if(!config.sql_enabled)
|
|
log_unit_test("[ascii_yellow]--------------- Database not Configured - Skipping Preference Column UT")
|
|
return TRUE
|
|
|
|
log_unit_test("[ascii_yellow]--------------- Database Configured - Running SQL Preference UTs")
|
|
|
|
if(!establish_db_connection(dbcon))
|
|
log_unit_test("[ascii_red]--------------- Unable to establish database connection.")
|
|
fail("Database connection could not be established.")
|
|
return TRUE
|
|
|
|
var/faults = 0
|
|
var/valid_columns = list()
|
|
|
|
// this is the worst unit test in the history of unit tests - geeves
|
|
// At least the credentials are no longer hardcoded - arrow768
|
|
var/list/table_names = list(
|
|
"ss13_characters",
|
|
"ss13_characters_flavour",
|
|
"ss13_player",
|
|
"ss13_player_preferences",
|
|
"ss13_player_pai",
|
|
"ss13_characters_ipc_tags"
|
|
)
|
|
for (var/T in table_names)
|
|
var/DBQuery/get_cs = dbcon.NewQuery("SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_NAME` = :table:")
|
|
get_cs.Execute(list("table" = T))
|
|
|
|
if (get_cs.ErrorMsg())
|
|
log_unit_test("[ascii_red]--------------- SQL error encountered: [get_cs.ErrorMsg()].[ascii_reset]")
|
|
fail("SQL error encountered.")
|
|
return TRUE
|
|
|
|
valid_columns[T] = list()
|
|
|
|
while (get_cs.NextRow())
|
|
valid_columns[T][get_cs.item[1]] = TRUE
|
|
|
|
var/datum/preferences/P = new(null)
|
|
|
|
for (var/datum/category_group/player_setup_category/G in P.player_setup.categories)
|
|
for (var/datum/category_item/player_setup_item/A in G.items)
|
|
var/list/test_columns = list()
|
|
var/list/temp
|
|
|
|
temp = A.gather_load_query()
|
|
for (var/B in temp)
|
|
if (!test_columns[B])
|
|
test_columns[B] = list()
|
|
|
|
test_columns[B] |= temp[B]["vars"]
|
|
test_columns[B] |= temp[B]["args"]
|
|
temp.Cut()
|
|
|
|
temp = A.gather_load_parameters()
|
|
var/list/unfound = temp.Copy()
|
|
for (var/C in temp)
|
|
for (var/B in test_columns)
|
|
if (C in test_columns[B])
|
|
unfound -= C
|
|
break
|
|
|
|
if (unfound.len)
|
|
for (var/C in unfound)
|
|
log_unit_test("[ascii_red]--------------- load parameter '[C]' not found in any queries for '[A.name]':[A.type].[ascii_reset]")
|
|
faults++
|
|
temp.Cut()
|
|
|
|
temp = A.gather_save_query()
|
|
for (var/B in temp)
|
|
if (!test_columns[B])
|
|
test_columns[B] = list()
|
|
|
|
test_columns[B] |= temp[B]
|
|
temp.Cut()
|
|
|
|
for (var/B in test_columns)
|
|
var/list/valids = valid_columns[B]
|
|
if (!valids || !valids.len)
|
|
log_unit_test("[ascii_red]--------------- table '[B]' referenced but not found for '[A.name]':[A.type].[ascii_reset]")
|
|
faults++
|
|
continue
|
|
|
|
for (var/C in test_columns[B])
|
|
if (!(C in valids))
|
|
log_unit_test("[ascii_red]--------------- column '[C]' referenced but not in table '[B]' for item '[A.name]':[A.type].[ascii_reset]")
|
|
faults++
|
|
|
|
if (faults)
|
|
fail("\[[faults]\] faults found in the SQL preferences setup.")
|
|
else
|
|
pass("No faults found in the SQL preferences setup.")
|
|
|
|
return TRUE
|
|
|
|
/datum/unit_test/sql_preferences_vars
|
|
name = "SQL: Preferences Variables"
|
|
|
|
/datum/unit_test/sql_preferences_vars/start_test()
|
|
var/faults = 0
|
|
var/total = 0
|
|
var/datum/preferences/P = new(null)
|
|
|
|
for (var/datum/category_group/player_setup_category/G in P.player_setup.categories)
|
|
for (var/datum/category_item/player_setup_item/A in G.items)
|
|
var/list/test = list()
|
|
var/list/temp = A.gather_load_query()
|
|
|
|
for (var/B in temp)
|
|
var/list/some_vars = temp[B]["vars"]
|
|
for (var/C in some_vars)
|
|
if (some_vars[C])
|
|
C = some_vars[C]
|
|
var/list/layers = splittext(C, "/")
|
|
if (layers.len == 1)
|
|
test |= C
|
|
else
|
|
test |= layers[1]
|
|
else
|
|
test |= C
|
|
|
|
total += test.len
|
|
for (var/V in test)
|
|
if (!(V in P.vars))
|
|
log_unit_test("[ascii_red]--------------- variable '[V]' referenced by, but not found in preferences class variables, '[A.name]':[A.type].[ascii_reset]")
|
|
faults++
|
|
|
|
if (faults)
|
|
fail("\[[faults] / [total]\] variable references found invalid in the SQL preferences setup.")
|
|
else
|
|
pass("All \[[total]\] variable references found valid in the SQL preferences setup.")
|
|
|
|
return TRUE
|