pgsql-test 2.1.12 โ 2.1.13
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 +13 -9
- package/esm/manager.js +4 -4
- package/esm/test-client.js +6 -2
- package/manager.js +4 -4
- package/package.json +4 -4
- package/test-client.d.ts +1 -0
- package/test-client.js +6 -2
package/README.md
CHANGED
|
@@ -259,10 +259,12 @@ let db;
|
|
|
259
259
|
let teardown;
|
|
260
260
|
|
|
261
261
|
beforeAll(async () => {
|
|
262
|
-
({ db, teardown } = await getConnections({},
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
({ db, teardown } = await getConnections({}, [
|
|
263
|
+
seed.sqlfile([
|
|
264
|
+
sql('schema.sql'),
|
|
265
|
+
sql('fixtures.sql')
|
|
266
|
+
])
|
|
267
|
+
]));
|
|
266
268
|
});
|
|
267
269
|
|
|
268
270
|
afterAll(async () => {
|
|
@@ -281,11 +283,13 @@ let db;
|
|
|
281
283
|
let teardown;
|
|
282
284
|
|
|
283
285
|
beforeAll(async () => {
|
|
284
|
-
({ db, teardown } = await getConnections({},
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
286
|
+
({ db, teardown } = await getConnections({}, [
|
|
287
|
+
seed.fn(async ({ pg }) => {
|
|
288
|
+
await pg.query(`
|
|
289
|
+
INSERT INTO users (name) VALUES ('Seeded User');
|
|
290
|
+
`);
|
|
291
|
+
})
|
|
292
|
+
]));
|
|
289
293
|
});
|
|
290
294
|
```
|
|
291
295
|
|
package/esm/manager.js
CHANGED
|
@@ -62,7 +62,7 @@ export class PgTestConnector {
|
|
|
62
62
|
return client;
|
|
63
63
|
}
|
|
64
64
|
async closeAll() {
|
|
65
|
-
log.info('
|
|
65
|
+
log.info('๐งน Closing all PgTestClients...');
|
|
66
66
|
await Promise.all(Array.from(this.clients).map(async (client) => {
|
|
67
67
|
try {
|
|
68
68
|
await client.close();
|
|
@@ -73,13 +73,13 @@ export class PgTestConnector {
|
|
|
73
73
|
}
|
|
74
74
|
}));
|
|
75
75
|
this.clients.clear();
|
|
76
|
-
log.info('
|
|
76
|
+
log.info('๐งฏ Disposing pg pools...');
|
|
77
77
|
for (const [key, pool] of this.pgPools.entries()) {
|
|
78
78
|
log.debug(`๐งฏ Disposing pg pool [${key}]`);
|
|
79
79
|
end(pool);
|
|
80
80
|
}
|
|
81
81
|
this.pgPools.clear();
|
|
82
|
-
log.info('
|
|
82
|
+
log.info('๐๏ธ Dropping seen databases...');
|
|
83
83
|
await Promise.all(Array.from(this.seenDbConfigs.values()).map(async (config) => {
|
|
84
84
|
try {
|
|
85
85
|
const rootPg = getPgEnvOptions();
|
|
@@ -92,7 +92,7 @@ export class PgTestConnector {
|
|
|
92
92
|
}
|
|
93
93
|
}));
|
|
94
94
|
this.seenDbConfigs.clear();
|
|
95
|
-
log.success('
|
|
95
|
+
log.success('โ
All PgTestClients closed, pools disposed, databases dropped.');
|
|
96
96
|
}
|
|
97
97
|
close() {
|
|
98
98
|
this.closeAll();
|
package/esm/test-client.js
CHANGED
|
@@ -79,10 +79,14 @@ export class PgTestClient {
|
|
|
79
79
|
return this.query(query, values);
|
|
80
80
|
}
|
|
81
81
|
async query(query, values) {
|
|
82
|
+
await this.ctxQuery();
|
|
83
|
+
const result = await this.client.query(query, values);
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
// exposing so we can use for graphile-test
|
|
87
|
+
async ctxQuery() {
|
|
82
88
|
if (this.ctxStmts) {
|
|
83
89
|
await this.client.query(this.ctxStmts);
|
|
84
90
|
}
|
|
85
|
-
const result = await this.client.query(query, values);
|
|
86
|
-
return result;
|
|
87
91
|
}
|
|
88
92
|
}
|
package/manager.js
CHANGED
|
@@ -65,7 +65,7 @@ class PgTestConnector {
|
|
|
65
65
|
return client;
|
|
66
66
|
}
|
|
67
67
|
async closeAll() {
|
|
68
|
-
log.info('
|
|
68
|
+
log.info('๐งน Closing all PgTestClients...');
|
|
69
69
|
await Promise.all(Array.from(this.clients).map(async (client) => {
|
|
70
70
|
try {
|
|
71
71
|
await client.close();
|
|
@@ -76,13 +76,13 @@ class PgTestConnector {
|
|
|
76
76
|
}
|
|
77
77
|
}));
|
|
78
78
|
this.clients.clear();
|
|
79
|
-
log.info('
|
|
79
|
+
log.info('๐งฏ Disposing pg pools...');
|
|
80
80
|
for (const [key, pool] of this.pgPools.entries()) {
|
|
81
81
|
log.debug(`๐งฏ Disposing pg pool [${key}]`);
|
|
82
82
|
end(pool);
|
|
83
83
|
}
|
|
84
84
|
this.pgPools.clear();
|
|
85
|
-
log.info('
|
|
85
|
+
log.info('๐๏ธ Dropping seen databases...');
|
|
86
86
|
await Promise.all(Array.from(this.seenDbConfigs.values()).map(async (config) => {
|
|
87
87
|
try {
|
|
88
88
|
const rootPg = (0, types_1.getPgEnvOptions)();
|
|
@@ -95,7 +95,7 @@ class PgTestConnector {
|
|
|
95
95
|
}
|
|
96
96
|
}));
|
|
97
97
|
this.seenDbConfigs.clear();
|
|
98
|
-
log.success('
|
|
98
|
+
log.success('โ
All PgTestClients closed, pools disposed, databases dropped.');
|
|
99
99
|
}
|
|
100
100
|
close() {
|
|
101
101
|
this.closeAll();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-test",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.13",
|
|
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",
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
"@types/pg-copy-streams": "^1.2.5"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@launchql/migrate": "^2.1.
|
|
63
|
-
"@launchql/server-utils": "^2.1.
|
|
62
|
+
"@launchql/migrate": "^2.1.12",
|
|
63
|
+
"@launchql/server-utils": "^2.1.7",
|
|
64
64
|
"@launchql/types": "^2.1.5",
|
|
65
65
|
"chalk": "^4.1.0",
|
|
66
66
|
"deepmerge": "^4.3.1",
|
|
67
67
|
"pg": "^8.16.0",
|
|
68
68
|
"pg-copy-streams": "^6.0.6"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "94a9cdd4a89443ef5831a14a2c104b5b40572420"
|
|
71
71
|
}
|
package/test-client.d.ts
CHANGED
|
@@ -22,4 +22,5 @@ export declare class PgTestClient {
|
|
|
22
22
|
none(query: string, values?: any[]): Promise<void>;
|
|
23
23
|
result(query: string, values?: any[]): Promise<import('pg').QueryResult>;
|
|
24
24
|
query<T = any>(query: string, values?: any[]): Promise<QueryResult<T>>;
|
|
25
|
+
ctxQuery(): Promise<void>;
|
|
25
26
|
}
|
package/test-client.js
CHANGED
|
@@ -82,11 +82,15 @@ class PgTestClient {
|
|
|
82
82
|
return this.query(query, values);
|
|
83
83
|
}
|
|
84
84
|
async query(query, values) {
|
|
85
|
+
await this.ctxQuery();
|
|
86
|
+
const result = await this.client.query(query, values);
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
// exposing so we can use for graphile-test
|
|
90
|
+
async ctxQuery() {
|
|
85
91
|
if (this.ctxStmts) {
|
|
86
92
|
await this.client.query(this.ctxStmts);
|
|
87
93
|
}
|
|
88
|
-
const result = await this.client.query(query, values);
|
|
89
|
-
return result;
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
exports.PgTestClient = PgTestClient;
|