MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeFakeSql

Function makeFakeSql

apps/cloud/src/db/code-migration-runner.test.ts:10–32  ·  view source on GitHub ↗
(options: { readonly ledgerExists?: boolean; readonly stamped?: string[] })

Source from the content-addressed store, hash-verified

8} from "../../scripts/code-migrations/runner";
9
10const makeFakeSql = (options: { readonly ledgerExists?: boolean; readonly stamped?: string[] }) => {
11 const log: { readonly query: string; readonly params?: readonly unknown[] }[] = [];
12 const stamped = [...(options.stamped ?? [])];
13 const sql: CodeMigrationSql = {
14 unsafe: (query, params) => {
15 log.push({ query, params });
16 if (query.includes("to_regclass")) {
17 const rows = [
18 { ledger_table: options.ledgerExists === false ? null : "cloud_code_migration" },
19 ];
20 return Promise.resolve(rows as never);
21 }
22 if (query.includes('SELECT "name" FROM "cloud_code_migration"')) {
23 return Promise.resolve(stamped.map((name) => ({ name })) as never);
24 }
25 if (query.includes('INSERT INTO "cloud_code_migration"')) {
26 stamped.push(String(params?.[0]));
27 }
28 return Promise.resolve([] as never);
29 },
30 };
31 return { sql, log, stamped };
32};
33
34const migrationSpy = (name: string): { migration: CodeMigration; calls: boolean[] } => {
35 const calls: boolean[] = [];

Callers 1

Calls 2

pushMethod · 0.80
resolveMethod · 0.80

Tested by

no test coverage detected