pgsql-test 2.11.3 → 2.11.4
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/admin.js +10 -3
- package/connect.js +13 -5
- package/esm/admin.js +10 -3
- package/esm/connect.js +13 -5
- package/package.json +3 -3
package/admin.js
CHANGED
|
@@ -114,11 +114,18 @@ class DbAdmin {
|
|
|
114
114
|
const adminRole = (0, roles_1.getRoleName)('administrator', this.roleConfig);
|
|
115
115
|
const sql = `
|
|
116
116
|
DO $$
|
|
117
|
+
DECLARE
|
|
118
|
+
v_user TEXT := '${user.replace(/'/g, "''")}';
|
|
119
|
+
v_password TEXT := '${password.replace(/'/g, "''")}';
|
|
117
120
|
BEGIN
|
|
118
121
|
-- Create role if it doesn't exist
|
|
119
|
-
|
|
120
|
-
CREATE ROLE
|
|
121
|
-
|
|
122
|
+
BEGIN
|
|
123
|
+
EXECUTE format('CREATE ROLE %I LOGIN PASSWORD %L', v_user, v_password);
|
|
124
|
+
EXCEPTION
|
|
125
|
+
WHEN duplicate_object THEN
|
|
126
|
+
-- Role already exists; optionally sync attributes here with ALTER ROLE
|
|
127
|
+
NULL;
|
|
128
|
+
END;
|
|
122
129
|
|
|
123
130
|
-- Grant anonymous role if not already granted
|
|
124
131
|
IF NOT EXISTS (
|
package/connect.js
CHANGED
|
@@ -49,10 +49,16 @@ const getConnections = async (cn = {}, seedAdapters = [seed_1.seed.launchql()])
|
|
|
49
49
|
await admin.grantConnect(connOpts.connection.user, config.database);
|
|
50
50
|
manager = manager_1.PgTestConnector.getInstance();
|
|
51
51
|
const pg = manager.getClient(config);
|
|
52
|
+
let teardownPromise = null;
|
|
52
53
|
const teardown = async () => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
if (teardownPromise)
|
|
55
|
+
return teardownPromise;
|
|
56
|
+
teardownPromise = (async () => {
|
|
57
|
+
manager.beginTeardown();
|
|
58
|
+
await (0, pg_cache_1.teardownPgPools)();
|
|
59
|
+
await manager.closeAll();
|
|
60
|
+
})();
|
|
61
|
+
return teardownPromise;
|
|
56
62
|
};
|
|
57
63
|
if (seedAdapters.length) {
|
|
58
64
|
try {
|
|
@@ -64,8 +70,10 @@ const getConnections = async (cn = {}, seedAdapters = [seed_1.seed.launchql()])
|
|
|
64
70
|
});
|
|
65
71
|
}
|
|
66
72
|
catch (error) {
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
const err = error;
|
|
74
|
+
const msg = err && (err.stack || err.message) ? (err.stack || err.message) : String(err);
|
|
75
|
+
process.stderr.write(`[pgsql-test] Seed error (continuing): ${msg}\n`);
|
|
76
|
+
// continue without teardown to allow caller-managed lifecycle
|
|
69
77
|
}
|
|
70
78
|
}
|
|
71
79
|
const dbConfig = {
|
package/esm/admin.js
CHANGED
|
@@ -111,11 +111,18 @@ export class DbAdmin {
|
|
|
111
111
|
const adminRole = getRoleName('administrator', this.roleConfig);
|
|
112
112
|
const sql = `
|
|
113
113
|
DO $$
|
|
114
|
+
DECLARE
|
|
115
|
+
v_user TEXT := '${user.replace(/'/g, "''")}';
|
|
116
|
+
v_password TEXT := '${password.replace(/'/g, "''")}';
|
|
114
117
|
BEGIN
|
|
115
118
|
-- Create role if it doesn't exist
|
|
116
|
-
|
|
117
|
-
CREATE ROLE
|
|
118
|
-
|
|
119
|
+
BEGIN
|
|
120
|
+
EXECUTE format('CREATE ROLE %I LOGIN PASSWORD %L', v_user, v_password);
|
|
121
|
+
EXCEPTION
|
|
122
|
+
WHEN duplicate_object THEN
|
|
123
|
+
-- Role already exists; optionally sync attributes here with ALTER ROLE
|
|
124
|
+
NULL;
|
|
125
|
+
END;
|
|
119
126
|
|
|
120
127
|
-- Grant anonymous role if not already granted
|
|
121
128
|
IF NOT EXISTS (
|
package/esm/connect.js
CHANGED
|
@@ -45,10 +45,16 @@ export const getConnections = async (cn = {}, seedAdapters = [seed.launchql()])
|
|
|
45
45
|
await admin.grantConnect(connOpts.connection.user, config.database);
|
|
46
46
|
manager = PgTestConnector.getInstance();
|
|
47
47
|
const pg = manager.getClient(config);
|
|
48
|
+
let teardownPromise = null;
|
|
48
49
|
const teardown = async () => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
if (teardownPromise)
|
|
51
|
+
return teardownPromise;
|
|
52
|
+
teardownPromise = (async () => {
|
|
53
|
+
manager.beginTeardown();
|
|
54
|
+
await teardownPgPools();
|
|
55
|
+
await manager.closeAll();
|
|
56
|
+
})();
|
|
57
|
+
return teardownPromise;
|
|
52
58
|
};
|
|
53
59
|
if (seedAdapters.length) {
|
|
54
60
|
try {
|
|
@@ -60,8 +66,10 @@ export const getConnections = async (cn = {}, seedAdapters = [seed.launchql()])
|
|
|
60
66
|
});
|
|
61
67
|
}
|
|
62
68
|
catch (error) {
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
const err = error;
|
|
70
|
+
const msg = err && (err.stack || err.message) ? (err.stack || err.message) : String(err);
|
|
71
|
+
process.stderr.write(`[pgsql-test] Seed error (continuing): ${msg}\n`);
|
|
72
|
+
// continue without teardown to allow caller-managed lifecycle
|
|
65
73
|
}
|
|
66
74
|
}
|
|
67
75
|
const dbConfig = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-test",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.4",
|
|
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",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@types/pg-copy-streams": "^1.2.5"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@launchql/core": "^2.11.
|
|
63
|
+
"@launchql/core": "^2.11.4",
|
|
64
64
|
"@launchql/env": "^2.4.1",
|
|
65
65
|
"@launchql/server-utils": "^2.4.1",
|
|
66
66
|
"@launchql/types": "^2.6.0",
|
|
@@ -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": "57f8c45ad88b59a054b4d8a95d53cf7ef16b8d8a"
|
|
73
73
|
}
|