refactor(test): migrate messages repo tests to createTestDb (section B2, part 2)#3500
Conversation
…B2, part 2) Convert the messages repository tests from hand-rolled `CREATE TABLE nodes` + `CREATE TABLE messages` DDL to the shared createTestDb() helper (the full production schema from the migration registry): - messages.insert, messages.timestamp, messages.purge, messages.createdAt-ordering, messages.exclude-portnums Each seeded its referenced nodes with a minimal (nodeNum, nodeId) insert; the real nodes schema requires sourceId (composite PK from migration 029) and createdAt/updatedAt, so the node seeds now include those. No behavior change — full suite green (6527). Part of the incremental B2 migration of ~40 hand-rolled-DDL test files. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review: refactor(test): migrate messages repo tests to createTestDb (section B2, part 2)Tasks
SummaryThis is a clean, well-executed refactor. The migration from hand-rolled DDL to Bug: Incomplete node seed in
|
claude-pr review on #3500 caught a real bug: the broadcast-node seed in the 'excludes broadcast messages' test still used a minimal INSERT OR IGNORE without sourceId/createdAt/updatedAt. OR IGNORE silently swallowed the NOT NULL violation, so the row never inserted (test passed only because FKs aren't enforced). Use the full parameterized insert like the rest of the file. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review: refactor(test): migrate messages repo tests to createTestDb (section B2, part 2)Tasks
SummaryThis is a clean, well-executed refactor. The migration from hand-rolled DDL to Previously identified bug: Fixed ✅The broadcast-node seed in // Fixed — all NOT NULL/PK columns present
db.prepare(
"INSERT OR IGNORE INTO nodes (nodeNum, nodeId, sourceId, createdAt, updatedAt) VALUES (?, ?, 'default', ?, ?)",
).run(0xffffffff, '!ffffffff', now, now);The inline comment at line 131–132 also documents exactly why the full column set is needed, which is a good addition for future readers. Remaining observations (minor/stylistic)
Test coverage quality — All five files cover the right edge cases:
No gaps found. The regression comments linking issue numbers (#2631, #2741, #3122) are particularly helpful. Positive observations
VerdictClean PR. The one substantive bug from the previous review has been addressed. No new issues found. |
Continues the section-B2 bulk migration: convert hand-rolled test DDL to the shared
createTestDb()helper (landed in #3498).Change
The five messages repository tests previously hand-rolled
CREATE TABLE nodes+CREATE TABLE messages(duplicatingsrc/db/schema/). They now usecreateTestDb()— the full production schema from the migration registry:messages.insert,messages.timestamp,messages.purge,messages.createdAt-ordering,messages.exclude-portnumsNote on the node seeding
Each test seeded its referenced nodes with a minimal
(nodeNum, nodeId)insert. The realnodesschema requiressourceId(composite PK(nodeNum, sourceId)from migration 029) andcreatedAt/updatedAtNOT NULL — so the node seeds now include those. This is the per-file friction of the migration: the full schema has stricter constraints than the simplified hand-rolled tables.Validation
tsc --noEmit: cleanRemaining B2 scope
~32 hand-rolled-DDL test files remain (nodes, auth, channels, meshcore, services, database facade, etc.). They have heterogeneous setups (different reference-data seeding, some multi-backend) so each batch needs individual verification — these will follow as further small, verified PRs. Intentionally left:
telemetry.multidb.test.ts(multi-backend by design) andschemaIntegrity.test.ts(asserts DDL alignment on purpose).🤖 Generated with Claude Code