Skip to content

Commit 35c17dd

Browse files
committed
database/test: attempting to actually fix testing the database in the database package -_-
1 parent 59131f7 commit 35c17dd

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/packages/database/jest.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ module.exports = {
33
preset: 'ts-jest',
44
testEnvironment: 'node',
55
testMatch: ['**/?(*.)+(spec|test).ts?(x)'],
6+
setupFiles: ['./test/setup.js'], // Path to your setup file
67
};

src/packages/database/postgres/bulk-delete.test.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
* License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
44
*/
55

6-
// see packages/database/pool/pool.ts for where this name is also hard coded:
7-
process.env.PGDATABASE = "smc_ephemeral_testing_database";
8-
96
import getPool, { initEphemeralDatabase } from "@cocalc/database/pool";
107
import { uuid } from "@cocalc/util/misc";
118
import { bulk_delete } from "./bulk-delete";
129

1310
beforeAll(async () => {
14-
await initEphemeralDatabase({ reset: true });
11+
await initEphemeralDatabase({});
1512
}, 15000);
1613

1714
afterAll(async () => {

src/packages/database/postgres/site-license/hook.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* The quota function uses a deep copy operation on all its arguments to avoid this.
1515
*/
1616

17-
// see packages/database/pool/pool.ts for where this name is also hard coded:
18-
process.env.PGDATABASE = "smc_ephemeral_testing_database";
1917

2018
import { isEqual } from "lodash";
2119

src/packages/database/test/setup.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// test/setup.js
2+
3+
// see packages/database/pool/pool.ts for where this name is also hard coded:
4+
process.env.PGDATABASE = "smc_ephemeral_testing_database";
5+
6+
// checked for in some code to behave differently while running unit tests.
7+
process.env.COCALC_TEST_MODE = true;

0 commit comments

Comments
 (0)