-
-
Notifications
You must be signed in to change notification settings - Fork 229
Expand file tree
/
Copy pathtest-seed.mjs
More file actions
32 lines (27 loc) · 648 Bytes
/
test-seed.mjs
File metadata and controls
32 lines (27 loc) · 648 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env zx
import pg from "pg";
import { fs } from "zx";
const { Pool } = pg;
if (process.env.IN_TESTS !== "1") {
process.exit(0);
}
async function main() {
const connectionString = process.env.GM_DBURL;
if (!connectionString) {
throw new Error("GM_DBURL not set!");
}
const pgPool = new Pool({ connectionString });
try {
await pgPool.query("delete from graphile_worker.jobs;");
await fs.writeFile(
`${__dirname}/../__tests__/jest.watch.hack.ts`,
`export const ts = ${Date.now()};\n`
);
} finally {
await pgPool.end();
}
}
main().catch((e) => {
console.error(e);
process.exit(1);
});