test(storage): integration test for migrate-tier PGlite → federated PG (FED-M1-08)
Seeds a temp PGlite with representative cross-table data (users, teams, team_members, conversations, messages), runs mosaic storage migrate-tier against a live federated PG+pgvector profile, asserts exact row counts and spot-checks key columns. Gated by FEDERATED_INTEGRATION=1. Caught and fixed P0 bug in migrate-tier: PostgresMigrationTarget passed Drizzle-selected camelCase keys (emailVerified, userId, ...) verbatim as SQL identifiers, failing on Postgres which expects snake_case. The 32 unit tests missed this because both source and target were mocked. normaliseSourceRow now applies toSnakeCase conversion that is idempotent on already-snake_case keys. Test infrastructure: - packages/storage/src/test-utils/pglite-with-vector.ts: PGlite + @electric-sql/pglite/vector (JS-native pgvector) and migration runner. Co-located with storage tests rather than exposed on @mosaicstack/db public surface (would have polluted prod consumers with WASM bundle). - packages/storage now declared "type": "module" (codebase convention, required for import.meta.url in test-utils). afterAll cleanup deletes prefix-namespaced rows even on test panic. Refs #460
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
"url": "https://git.mosaicstack.dev/mosaicstack/stack.git",
|
||||
"directory": "packages/storage"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
@@ -29,6 +30,7 @@
|
||||
"postgres": "^3.4.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"drizzle-orm": "^0.45.1",
|
||||
"typescript": "^5.8.0",
|
||||
"vitest": "^2.0.0"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user