tools: name players through player.setname, and the character groups and four fault classes (#23)
This commit is contained in:
@@ -49,16 +49,16 @@ test('a fresh DB is created and migrated; re-opening applies nothing', async ()
|
||||
const first = await startServer({ stateDir })
|
||||
const firstLog = first.log()
|
||||
await stopServer(first)
|
||||
assert.match(firstLog, /db_ready .*schema_version=6 applied=6/, firstLog)
|
||||
assert.match(firstLog, /db_ready .*schema_version=7 applied=7/, firstLog)
|
||||
assert.ok(fs.existsSync(first.dbPath), 'state.db was not created')
|
||||
|
||||
const db = new DatabaseSync(first.dbPath)
|
||||
try {
|
||||
assert.equal(Number(db.prepare('PRAGMA user_version').get().user_version), 6)
|
||||
assert.equal(Number(db.prepare('PRAGMA user_version').get().user_version), 7)
|
||||
const rows = db.prepare('SELECT version, name FROM schema_migration ORDER BY version').all()
|
||||
assert.deepEqual(rows.map(r => [Number(r.version), r.name]),
|
||||
[[1, 'meta'], [2, 'auth'], [3, 'world'], [4, 'tokens'], [5, 'explored'],
|
||||
[6, 'token details']])
|
||||
[6, 'token details'], [7, 'characters']])
|
||||
assert.equal(Number(db.prepare('SELECT count(*) AS n FROM meta').get().n), 0)
|
||||
assert.equal(Number(db.prepare('SELECT count(*) AS n FROM player').get().n), 0)
|
||||
// step 3 seeds the single v1 scene (Q3) with no walls and a counter at 1
|
||||
@@ -71,10 +71,14 @@ test('a fresh DB is created and migrated; re-opening applies nothing', async ()
|
||||
assert.equal(Number(db.prepare('SELECT count(*) AS n FROM explored_chunk').get().n), 0)
|
||||
// step 6 adds the three prop buckets and the status set (DESIGN 5.5, 8; #22), empty
|
||||
assert.equal(Number(db.prepare('SELECT count(*) AS n FROM entity_status').get().n), 0)
|
||||
for (const col of ['props_public', 'props_owner', 'props_gm']) {
|
||||
for (const col of ['props_public', 'props_owner', 'props_gm', 'character_id', 'reveal_all']) {
|
||||
assert.equal(Number(db.prepare(`SELECT count(*) AS n FROM pragma_table_info('entity')
|
||||
WHERE name = '${col}'`).get().n), 1, col)
|
||||
}
|
||||
// step 7 creates the character world (DESIGN 8, #23), empty
|
||||
for (const table of ['character', 'name_reveal', 'encountered']) {
|
||||
assert.equal(Number(db.prepare(`SELECT count(*) AS n FROM ${table}`).get().n), 0, table)
|
||||
}
|
||||
assert.equal(db.prepare('PRAGMA journal_mode').get().journal_mode, 'wal')
|
||||
} finally {
|
||||
db.close()
|
||||
@@ -83,7 +87,7 @@ test('a fresh DB is created and migrated; re-opening applies nothing', async ()
|
||||
const second = await startServer({ stateDir })
|
||||
const secondLog = second.log().slice(firstLog.length)
|
||||
await stopServer(second)
|
||||
assert.match(secondLog, /db_ready .*schema_version=6 applied=0/, secondLog)
|
||||
assert.match(secondLog, /db_ready .*schema_version=7 applied=0/, secondLog)
|
||||
assert.doesNotMatch(secondLog, /applied=[1-9]/)
|
||||
} finally {
|
||||
fs.rmSync(stateDir, { recursive: true, force: true })
|
||||
|
||||
Reference in New Issue
Block a user