import { expect, test } from "vitest"; import { MemoryCatalogRepository } from "../src/catalog/memory-repository.js"; test("the in-memory Catalog enforces the same attempt identity as PostgreSQL", async () => { const repository = new MemoryCatalogRepository(); const database = await repository.create({ workspaceId: "retry", engine: "postgres", databaseName: "warehouse", schema: "public", binding: { transport: "postgres_direct", host: "db", port: 5432, username: "reader" } }); await repository.applySchemaSync(database.id, database.version, "all", [], { schemaVersion: 1, capabilities: { tables: "available", columns: "available", relationships: "available" }, tables: [], columns: [], relationships: [], }); const revision = (await repository.get(database.id))!.metadataContentRevision; const fingerprint = "sha256:" + "1".repeat(64); await repository.beginPreprocessing("retry", fingerprint, "old"); await repository.finishPreprocessing("retry", revision, fingerprint, { status: "failed", errorCode: "preprocessing_interrupted" }, "old"); await repository.beginPreprocessing("retry", fingerprint, "replacement"); expect(await repository.finishPreprocessing("retry", revision, fingerprint, { status: "succeeded" }, "old")).toBeUndefined(); expect(await repository.finishPreprocessing("retry", revision, fingerprint, { status: "succeeded" }, "replacement")) .toMatchObject({ preprocessingStatus: "succeeded" }); });