feat: unify installation model catalog
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { expect, test, vi } from "vitest";
|
||||
import { buildInstallationContract } from "../src/workspaces/contracts.js";
|
||||
import {
|
||||
createProductionWorkspaceDiagnoser,
|
||||
createWorkspaceDiagnoser,
|
||||
type DiagnosticAdapters,
|
||||
} from "../src/workspaces/diagnostics.js";
|
||||
import {
|
||||
resolveBinding,
|
||||
resolveEvidenceBinding,
|
||||
resolveRuntimeBindings,
|
||||
} from "../src/workspaces/bindings.js";
|
||||
import { renderRuntimeConfig, type RuntimeBindings } from "../src/workspaces/runtime-renderer.js";
|
||||
|
||||
const unsupportedWorkspace = {
|
||||
workspace: { schema_version: 3, id: "legacy-workspace", name: "Legacy", language: "en" },
|
||||
dwh: {
|
||||
engine: "postgres", database: "warehouse", schema: "public",
|
||||
supported_transports: ["postgres_direct"],
|
||||
},
|
||||
};
|
||||
|
||||
const bindings: RuntimeBindings = {
|
||||
dwh: { transport: "postgres_direct", values: {}, missing: [] },
|
||||
evidence: { values: {}, missing: [] },
|
||||
};
|
||||
|
||||
const adapters: DiagnosticAdapters = {
|
||||
probeConnector: vi.fn(),
|
||||
inspectQdrant: vi.fn(),
|
||||
probeEmbedding: vi.fn(),
|
||||
};
|
||||
|
||||
test("renderer rejects callers that bypass the schema-v4 type contract", () => {
|
||||
expect(() => renderRuntimeConfig(unsupportedWorkspace as never, bindings, {
|
||||
sessions: "/data/sessions", artifacts: "/data/artifacts", indexes: "/data/indexes",
|
||||
})).toThrow("Runtime renderer supports only workspace schema version 4");
|
||||
});
|
||||
|
||||
test("installation contract rejects callers that bypass the schema-v4 type contract", () => {
|
||||
expect(() => buildInstallationContract(unsupportedWorkspace as never))
|
||||
.toThrow("Installation contract supports only workspace schema version 4");
|
||||
});
|
||||
|
||||
test("binding entry points reject callers that bypass the schema-v4 type contract", () => {
|
||||
expect(() => resolveBinding(unsupportedWorkspace as never, "DWH", {}, []))
|
||||
.toThrow("Workspace bindings support only workspace schema version 4");
|
||||
expect(() => resolveEvidenceBinding(unsupportedWorkspace as never, {}, []))
|
||||
.toThrow("Workspace bindings support only workspace schema version 4");
|
||||
expect(() => resolveRuntimeBindings(unsupportedWorkspace as never, {}, []))
|
||||
.toThrow("Workspace bindings support only workspace schema version 4");
|
||||
});
|
||||
|
||||
test("diagnoser factories reject callers that bypass the schema-v4 type contract", async () => {
|
||||
await expect(createWorkspaceDiagnoser(adapters)(unsupportedWorkspace as never, bindings, {
|
||||
writeProbe: false,
|
||||
})).rejects.toThrow("Workspace diagnoser supports only workspace schema version 4");
|
||||
await expect(createProductionWorkspaceDiagnoser(5_000, adapters)(
|
||||
unsupportedWorkspace as never, bindings, { writeProbe: false },
|
||||
)).rejects.toThrow("Workspace diagnoser supports only workspace schema version 4");
|
||||
});
|
||||
Reference in New Issue
Block a user