63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { parsePlatformLeadBackfillCliArgs } from "./backfill-cli.js";
|
|
|
|
describe("platform lead backfill CLI contract", () => {
|
|
it("parses a dry-run without database or mutation arguments", () => {
|
|
expect(
|
|
parsePlatformLeadBackfillCliArgs([
|
|
"--",
|
|
"--mode",
|
|
"dry-run",
|
|
"--store=hivegrid-website-staging-sqlite",
|
|
"--input",
|
|
"/tmp/staging.jsonl",
|
|
"--manifest",
|
|
"/tmp/staging.dry-run.json",
|
|
"--run-id",
|
|
"run-dry-1",
|
|
])
|
|
).toEqual({
|
|
mode: "dry-run",
|
|
legacyStore: "hivegrid-website-staging-sqlite",
|
|
inputPath: "/tmp/staging.jsonl",
|
|
manifestPath: "/tmp/staging.dry-run.json",
|
|
format: "jsonl",
|
|
runId: "run-dry-1",
|
|
});
|
|
});
|
|
|
|
it("requires hash, accepted count and actor for apply and replay", () => {
|
|
expect(() =>
|
|
parsePlatformLeadBackfillCliArgs(["--mode", "apply", "--store", "lead-inbox-postgres", "--input", "/tmp/input.jsonl", "--manifest", "/tmp/apply.json"])
|
|
).toThrow();
|
|
|
|
expect(
|
|
parsePlatformLeadBackfillCliArgs([
|
|
"--mode=replay",
|
|
"--store=hivegrid-cloud-legacy",
|
|
"--input=/tmp/leads.jsonl",
|
|
"--manifest=/tmp/replay.json",
|
|
"--actor-admin-user-id=operator_1",
|
|
`--expected-input-sha256=${"a".repeat(64)}`,
|
|
"--expected-accepted=2",
|
|
"--run-id=replay-1",
|
|
])
|
|
).toMatchObject({
|
|
mode: "replay",
|
|
legacyStore: "hivegrid-cloud-legacy",
|
|
format: "jsonl",
|
|
actorAdminUserId: "operator_1",
|
|
expectedInputSha256: "a".repeat(64),
|
|
expectedAccepted: 2,
|
|
});
|
|
});
|
|
|
|
it("rejects mutation-only proof arguments during dry-run and unknown arguments", () => {
|
|
const base = ["--mode=dry-run", "--store=hivegrid-cloud-legacy", "--input=/tmp/leads.jsonl", "--manifest=/tmp/dry.json"];
|
|
expect(() => parsePlatformLeadBackfillCliArgs([...base, "--expected-accepted=2"])).toThrow();
|
|
expect(() => parsePlatformLeadBackfillCliArgs([...base, "--secret=must-not-exist"])).toThrow();
|
|
expect(() => parsePlatformLeadBackfillCliArgs([...base, "--format=csv"])).toThrow();
|
|
});
|
|
});
|