tests: characters, names, the encountered list and migration step 7 (#23)
This commit is contained in:
+18
-9
@@ -38,9 +38,9 @@ suite "migrate":
|
||||
check migrate(db) == LatestVersion
|
||||
check LatestVersion == migrations[^1].version
|
||||
check schemaVersion(db) == LatestVersion
|
||||
check LatestVersion == 6
|
||||
check LatestVersion == 7
|
||||
let rows = appliedMigrations(db)
|
||||
check rows.len == 6
|
||||
check rows.len == 7
|
||||
check rows[0][0] == 1
|
||||
check rows[0][1] == "meta"
|
||||
check rows[1][0] == 2
|
||||
@@ -53,6 +53,8 @@ suite "migrate":
|
||||
check rows[4][1] == "explored"
|
||||
check rows[5][0] == 6
|
||||
check rows[5][1] == "token details"
|
||||
check rows[6][0] == 7
|
||||
check rows[6][1] == "characters"
|
||||
# the steps' own DDL ran: meta and the auth tables exist and are empty
|
||||
check db.getValue(sql"SELECT count(*) FROM meta") == "0"
|
||||
check db.getValue(sql"SELECT count(*) FROM player") == "0"
|
||||
@@ -69,12 +71,18 @@ suite "migrate":
|
||||
check db.getValue(sql"SELECT count(*) FROM entity_status") == "0"
|
||||
for col in ["props_public", "props_owner", "props_gm"]:
|
||||
check db.getValue(sql("SELECT count(*) FROM pragma_table_info('entity') WHERE name = '" & col & "'")) == "1"
|
||||
# step 7 creates the character world and adds the link columns to the token table
|
||||
check db.getValue(sql"SELECT count(*) FROM character") == "0"
|
||||
check db.getValue(sql"SELECT count(*) FROM name_reveal") == "0"
|
||||
check db.getValue(sql"SELECT count(*) FROM encountered") == "0"
|
||||
for col in ["character_id", "reveal_all"]:
|
||||
check db.getValue(sql("SELECT count(*) FROM pragma_table_info('entity') WHERE name = '" & col & "'")) == "1"
|
||||
|
||||
test "re-open is a no-op: no step applied, history and timestamps untouched":
|
||||
let d = tmpDir()
|
||||
block:
|
||||
let db = openFresh(d)
|
||||
check migrate(db) == 6
|
||||
check migrate(db) == LatestVersion
|
||||
close(db)
|
||||
let db = openFresh(d)
|
||||
defer:
|
||||
@@ -83,7 +91,7 @@ suite "migrate":
|
||||
let before = appliedMigrations(db)
|
||||
check migrate(db) == 0
|
||||
check migrate(db) == 0
|
||||
check schemaVersion(db) == 6
|
||||
check schemaVersion(db) == LatestVersion
|
||||
check appliedMigrations(db) == before
|
||||
|
||||
test "history and user_version must agree":
|
||||
@@ -157,8 +165,8 @@ suite "migrate":
|
||||
check schemaVersion(db) == 2
|
||||
check db.getValue(sql"SELECT count(*) FROM sqlite_master WHERE name = 'scene'") == "0"
|
||||
|
||||
check migrate(db) == 4 # steps 3, 4, 5 and 6 run
|
||||
check schemaVersion(db) == 6
|
||||
check migrate(db) == LatestVersion - 2 # steps 3 to 7 run
|
||||
check schemaVersion(db) == LatestVersion
|
||||
check db.getValue(sql"SELECT count(*) FROM scene") == "1"
|
||||
check db.getValue(sql"SELECT next_wall_id FROM scene WHERE id = 1") == "1"
|
||||
check db.getValue(sql"SELECT count(*) FROM player WHERE role = 'gm'") == "1"
|
||||
@@ -190,11 +198,12 @@ suite "migrate":
|
||||
check schemaVersion(db) == 4
|
||||
check db.getValue(sql"SELECT count(*) FROM sqlite_master WHERE name = 'explored_chunk'") == "0"
|
||||
|
||||
check migrate(db) == 2 # steps 5 and 6 run
|
||||
check schemaVersion(db) == 6
|
||||
check appliedMigrations(db).len == 6
|
||||
check migrate(db) == 3 # steps 5, 6 and 7 run
|
||||
check schemaVersion(db) == LatestVersion
|
||||
check appliedMigrations(db).len == 7
|
||||
check appliedMigrations(db)[4] == (version: 5, name: "explored")
|
||||
check appliedMigrations(db)[5] == (version: 6, name: "token details")
|
||||
check appliedMigrations(db)[6] == (version: 7, name: "characters")
|
||||
# step 6: the status table exists, and the old token's buckets default to empty objects
|
||||
check db.getValue(sql"SELECT count(*) FROM entity_status") == "0"
|
||||
check db.getValue(sql"SELECT props_public || props_owner || props_gm FROM entity") == "{}{}{}"
|
||||
|
||||
Reference in New Issue
Block a user