Skip to content

Commit 5d7c4aa

Browse files
committedJul 10, 2024
database/test: attempting to actually fix testing the database in the database package
1 parent 59131f7 commit 5d7c4aa

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed
 

‎src/packages/database/jest.config.js

Lines changed: 1 addition & 0 deletions
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/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"build": "../node_modules/.bin/tsc --build && coffee -c -o dist/ ./",
5151
"clean": "rm -rf dist",
5252
"tsc": "../node_modules/.bin/tsc --watch --pretty --preserveWatchOutput",
53-
"test": "pnpm exec jest",
53+
"test": "TZ=UTC jest --forceExit --runInBand",
5454
"prepublishOnly": "pnpm test"
5555
},
5656
"repository": {

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

Lines changed: 1 addition & 4 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 7 additions & 0 deletions
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)