接入发布校准仓储接口
This commit is contained in:
@@ -62,4 +62,37 @@ describe("createD1Repository", () => {
|
||||
export_paths: {},
|
||||
});
|
||||
});
|
||||
|
||||
test("saves a manual performance snapshot using D1 prepare and bind", async () => {
|
||||
const run = vi.fn().mockResolvedValue({ success: true });
|
||||
const bind = vi.fn().mockReturnValue({ run });
|
||||
const prepare = vi.fn().mockReturnValue({ bind });
|
||||
const db = { prepare } as unknown as D1Database;
|
||||
|
||||
const repository = createD1Repository(db);
|
||||
|
||||
await repository.savePerformanceSnapshot({
|
||||
id: "perf_123",
|
||||
publication_id: "pub_123",
|
||||
source: "manual",
|
||||
window_label: "T+7d",
|
||||
metrics: { views: 1200 },
|
||||
feedback_summary: "用户追问案例依据",
|
||||
snapshot_at: "2026-07-01T12:00:00.000Z",
|
||||
});
|
||||
|
||||
expect(prepare).toHaveBeenCalledWith(
|
||||
expect.stringContaining("insert into performance_snapshots"),
|
||||
);
|
||||
expect(bind).toHaveBeenCalledWith(
|
||||
"perf_123",
|
||||
"pub_123",
|
||||
"manual",
|
||||
"T+7d",
|
||||
'{"views":1200}',
|
||||
"用户追问案例依据",
|
||||
null,
|
||||
"2026-07-01T12:00:00.000Z",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user