Files
Paradise/code/modules/unit_tests/sql.dm
AffectedArc07 0c8d95dd65 Travis Update Finale: Unit Tests + SQL Validation (#13331)
* SQL Validation, the first of many

* Initial test of the world loading

* This was prefixed when it shouldnt have been :v

* This also isnt a valid table

* Escape time

* Chmod

* This **should** work

* Oops

* RUST gone bust

* Please work

* Why did I do this twice

* I think I got it

* Fixes AFK SS

* AAAAAAAAAAAAAAAAAAAAAA

* Fixes AI cam runtime

* Cleanup

* *screams*

* Fare fixes

* Removes un-needed stuff

* I hope this works

* chmoooood

* SQL Version Unit Test

* Failure test

* Kinda ironic how I forgot this

* Task failed successfully

* Moves a global var around

* Bump SQL version in travis

* New test: SQL example DBconfig update

* Lets test an invalid version

* TASK FAILED SUCCESSFULLY

* Programmatic maplist generation

* Removes a duplicate check

* Lets try this

* What about this

* hnnng

* Lets just update BYOND
2020-06-27 01:26:58 -06:00

43 lines
1.2 KiB
Plaintext

// Unit test to check SQL version has been updated properly.,
/datum/unit_test/sql_version/Run()
// Check if the SQL version set in the code is equal to the travis DB config
if(config.sql_enabled && sql_version != SQL_VERSION)
Fail("SQL version error: Game is running V[SQL_VERSION] but config is V[sql_version]. You may need to update tools/travis/dbconfig.txt")
// Check if the travis DB config is up to date with the example dbconfig
// This proc is a little unclean but it works
var/example_db_version
var/list/Lines = file2list("config/example/dbconfig.txt")
for(var/t in Lines)
if(!t) continue
t = trim(t)
if(length(t) == 0)
continue
else if(copytext(t, 1, 2) == "#")
continue
var/pos = findtext(t, " ")
var/name = null
var/value = null
if(pos)
name = lowertext(copytext(t, 1, pos))
value = copytext(t, pos + 1)
else
name = lowertext(t)
if(!name)
continue
switch(name)
if("db_version")
example_db_version = text2num(value)
if(!example_db_version)
Fail("SQL version error: File config/example/dbconfig.txt does not have a valid SQL version set!")
if(example_db_version != SQL_VERSION)
Fail("SQL version error: Game is running V[SQL_VERSION] but config/example/dbconfig.txt is V[example_db_version].")