pgsql-test 2.11.7 → 2.11.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/connect.js +1 -1
- package/esm/connect.js +1 -1
- package/esm/manager.js +6 -4
- package/manager.d.ts +2 -1
- package/manager.js +6 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
|
|
19
19
|
`pgsql-test` gives you instant, isolated PostgreSQL databases for each test — with automatic transaction rollbacks, context switching, and clean seeding. Forget flaky tests and brittle environments. Write real SQL. Get real coverage. Stay fast.
|
|
20
20
|
|
|
21
|
+
If you're writing tests for Supabase, check out [`supabase-test`](https://www.npmjs.com/package/supabase-test) for Supabase-optimized defaults.
|
|
22
|
+
|
|
21
23
|
## Install
|
|
22
24
|
|
|
23
25
|
```sh
|
package/connect.js
CHANGED
|
@@ -51,7 +51,7 @@ const getConnections = async (cn = {}, seedAdapters = [seed_1.seed.launchql()])
|
|
|
51
51
|
admin.installExtensions(connOpts.extensions);
|
|
52
52
|
}
|
|
53
53
|
await admin.grantConnect(connOpts.connection.user, config.database);
|
|
54
|
-
manager = manager_1.PgTestConnector.getInstance();
|
|
54
|
+
manager = manager_1.PgTestConnector.getInstance(config);
|
|
55
55
|
const pg = manager.getClient(config);
|
|
56
56
|
let teardownPromise = null;
|
|
57
57
|
const teardown = async () => {
|
package/esm/connect.js
CHANGED
|
@@ -47,7 +47,7 @@ export const getConnections = async (cn = {}, seedAdapters = [seed.launchql()])
|
|
|
47
47
|
admin.installExtensions(connOpts.extensions);
|
|
48
48
|
}
|
|
49
49
|
await admin.grantConnect(connOpts.connection.user, config.database);
|
|
50
|
-
manager = PgTestConnector.getInstance();
|
|
50
|
+
manager = PgTestConnector.getInstance(config);
|
|
51
51
|
const pg = manager.getClient(config);
|
|
52
52
|
let teardownPromise = null;
|
|
53
53
|
const teardown = async () => {
|
package/esm/manager.js
CHANGED
|
@@ -23,10 +23,12 @@ export class PgTestConnector {
|
|
|
23
23
|
pgPools = new Map();
|
|
24
24
|
seenDbConfigs = new Map();
|
|
25
25
|
pendingConnects = new Set();
|
|
26
|
+
config;
|
|
26
27
|
verbose = false;
|
|
27
28
|
shuttingDown = false;
|
|
28
|
-
constructor(verbose = false) {
|
|
29
|
+
constructor(config, verbose = false) {
|
|
29
30
|
this.verbose = verbose;
|
|
31
|
+
this.config = config;
|
|
30
32
|
SYS_EVENTS.forEach((event) => {
|
|
31
33
|
process.on(event, () => {
|
|
32
34
|
log.info(`⏹ Received ${event}, closing all connections...`);
|
|
@@ -34,9 +36,9 @@ export class PgTestConnector {
|
|
|
34
36
|
});
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
|
-
static getInstance(verbose = false) {
|
|
39
|
+
static getInstance(config, verbose = false) {
|
|
38
40
|
if (!PgTestConnector.instance) {
|
|
39
|
-
PgTestConnector.instance = new PgTestConnector(verbose);
|
|
41
|
+
PgTestConnector.instance = new PgTestConnector(config, verbose);
|
|
40
42
|
}
|
|
41
43
|
return PgTestConnector.instance;
|
|
42
44
|
}
|
|
@@ -105,7 +107,7 @@ export class PgTestConnector {
|
|
|
105
107
|
log.info('🗑️ Dropping seen databases...');
|
|
106
108
|
await Promise.all(Array.from(this.seenDbConfigs.values()).map(async (config) => {
|
|
107
109
|
try {
|
|
108
|
-
const rootPg = getPgEnvOptions();
|
|
110
|
+
const rootPg = getPgEnvOptions(this.config);
|
|
109
111
|
const admin = new DbAdmin({ ...config, user: rootPg.user, password: rootPg.password }, this.verbose);
|
|
110
112
|
admin.drop();
|
|
111
113
|
log.warn(`🧨 Dropped database: ${config.database}`);
|
package/manager.d.ts
CHANGED
|
@@ -7,10 +7,11 @@ export declare class PgTestConnector {
|
|
|
7
7
|
private readonly pgPools;
|
|
8
8
|
private readonly seenDbConfigs;
|
|
9
9
|
private readonly pendingConnects;
|
|
10
|
+
private config;
|
|
10
11
|
private verbose;
|
|
11
12
|
private shuttingDown;
|
|
12
13
|
private constructor();
|
|
13
|
-
static getInstance(verbose?: boolean): PgTestConnector;
|
|
14
|
+
static getInstance(config: PgConfig, verbose?: boolean): PgTestConnector;
|
|
14
15
|
private poolKey;
|
|
15
16
|
private dbKey;
|
|
16
17
|
beginTeardown(): void;
|
package/manager.js
CHANGED
|
@@ -26,10 +26,12 @@ class PgTestConnector {
|
|
|
26
26
|
pgPools = new Map();
|
|
27
27
|
seenDbConfigs = new Map();
|
|
28
28
|
pendingConnects = new Set();
|
|
29
|
+
config;
|
|
29
30
|
verbose = false;
|
|
30
31
|
shuttingDown = false;
|
|
31
|
-
constructor(verbose = false) {
|
|
32
|
+
constructor(config, verbose = false) {
|
|
32
33
|
this.verbose = verbose;
|
|
34
|
+
this.config = config;
|
|
33
35
|
SYS_EVENTS.forEach((event) => {
|
|
34
36
|
process.on(event, () => {
|
|
35
37
|
log.info(`⏹ Received ${event}, closing all connections...`);
|
|
@@ -37,9 +39,9 @@ class PgTestConnector {
|
|
|
37
39
|
});
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
|
-
static getInstance(verbose = false) {
|
|
42
|
+
static getInstance(config, verbose = false) {
|
|
41
43
|
if (!PgTestConnector.instance) {
|
|
42
|
-
PgTestConnector.instance = new PgTestConnector(verbose);
|
|
44
|
+
PgTestConnector.instance = new PgTestConnector(config, verbose);
|
|
43
45
|
}
|
|
44
46
|
return PgTestConnector.instance;
|
|
45
47
|
}
|
|
@@ -108,7 +110,7 @@ class PgTestConnector {
|
|
|
108
110
|
log.info('🗑️ Dropping seen databases...');
|
|
109
111
|
await Promise.all(Array.from(this.seenDbConfigs.values()).map(async (config) => {
|
|
110
112
|
try {
|
|
111
|
-
const rootPg = (0, pg_env_1.getPgEnvOptions)();
|
|
113
|
+
const rootPg = (0, pg_env_1.getPgEnvOptions)(this.config);
|
|
112
114
|
const admin = new admin_1.DbAdmin({ ...config, user: rootPg.user, password: rootPg.password }, this.verbose);
|
|
113
115
|
admin.drop();
|
|
114
116
|
log.warn(`🧨 Dropped database: ${config.database}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-test",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.9",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
5
|
"description": "pgsql-test offers isolated, role-aware, and rollback-friendly PostgreSQL environments for integration tests — giving developers realistic test coverage without external state pollution",
|
|
6
6
|
"main": "index.js",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"pg-copy-streams": "^6.0.6",
|
|
70
70
|
"pg-env": "^1.1.0"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "7aeb70c79619545d937597b64af80962803f6901"
|
|
73
73
|
}
|