pgsql-test 2.11.6 โ 2.11.8
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/connect.d.ts +1 -1
- package/connect.js +7 -3
- package/esm/connect.js +7 -3
- package/esm/manager.js +6 -4
- package/manager.d.ts +2 -1
- package/manager.js +6 -4
- package/package.json +2 -2
package/connect.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { DbAdmin } from './admin';
|
|
|
4
4
|
import { PgTestConnector } from './manager';
|
|
5
5
|
import { SeedAdapter } from './seed/types';
|
|
6
6
|
import { PgTestClient } from './test-client';
|
|
7
|
-
export declare const getPgRootAdmin: (connOpts?: PgTestConnectionOptions) => DbAdmin;
|
|
7
|
+
export declare const getPgRootAdmin: (config: PgConfig, connOpts?: PgTestConnectionOptions) => DbAdmin;
|
|
8
8
|
export interface GetConnectionOpts {
|
|
9
9
|
pg?: Partial<PgConfig>;
|
|
10
10
|
db?: Partial<PgTestConnectionOptions>;
|
package/connect.js
CHANGED
|
@@ -10,8 +10,12 @@ const manager_1 = require("./manager");
|
|
|
10
10
|
const roles_1 = require("./roles");
|
|
11
11
|
const seed_1 = require("./seed");
|
|
12
12
|
let manager;
|
|
13
|
-
const getPgRootAdmin = (connOpts = {}) => {
|
|
13
|
+
const getPgRootAdmin = (config, connOpts = {}) => {
|
|
14
14
|
const opts = (0, pg_env_1.getPgEnvOptions)({
|
|
15
|
+
user: config.user,
|
|
16
|
+
password: config.password,
|
|
17
|
+
host: config.host,
|
|
18
|
+
port: config.port,
|
|
15
19
|
database: connOpts.rootDb
|
|
16
20
|
});
|
|
17
21
|
const admin = new admin_1.DbAdmin(opts, false, connOpts);
|
|
@@ -33,7 +37,7 @@ const getConnections = async (cn = {}, seedAdapters = [seed_1.seed.launchql()])
|
|
|
33
37
|
cn = getConnOopts(cn);
|
|
34
38
|
const config = cn.pg;
|
|
35
39
|
const connOpts = cn.db;
|
|
36
|
-
const root = (0, exports.getPgRootAdmin)(connOpts);
|
|
40
|
+
const root = (0, exports.getPgRootAdmin)(config, connOpts);
|
|
37
41
|
await root.createUserRole(connOpts.connection.user, connOpts.connection.password, connOpts.rootDb);
|
|
38
42
|
const admin = new admin_1.DbAdmin(config, false, connOpts);
|
|
39
43
|
if (process.env.TEST_DB) {
|
|
@@ -47,7 +51,7 @@ const getConnections = async (cn = {}, seedAdapters = [seed_1.seed.launchql()])
|
|
|
47
51
|
admin.installExtensions(connOpts.extensions);
|
|
48
52
|
}
|
|
49
53
|
await admin.grantConnect(connOpts.connection.user, config.database);
|
|
50
|
-
manager = manager_1.PgTestConnector.getInstance();
|
|
54
|
+
manager = manager_1.PgTestConnector.getInstance(config);
|
|
51
55
|
const pg = manager.getClient(config);
|
|
52
56
|
let teardownPromise = null;
|
|
53
57
|
const teardown = async () => {
|
package/esm/connect.js
CHANGED
|
@@ -7,8 +7,12 @@ import { PgTestConnector } from './manager';
|
|
|
7
7
|
import { getDefaultRole } from './roles';
|
|
8
8
|
import { seed } from './seed';
|
|
9
9
|
let manager;
|
|
10
|
-
export const getPgRootAdmin = (connOpts = {}) => {
|
|
10
|
+
export const getPgRootAdmin = (config, connOpts = {}) => {
|
|
11
11
|
const opts = getPgEnvOptions({
|
|
12
|
+
user: config.user,
|
|
13
|
+
password: config.password,
|
|
14
|
+
host: config.host,
|
|
15
|
+
port: config.port,
|
|
12
16
|
database: connOpts.rootDb
|
|
13
17
|
});
|
|
14
18
|
const admin = new DbAdmin(opts, false, connOpts);
|
|
@@ -29,7 +33,7 @@ export const getConnections = async (cn = {}, seedAdapters = [seed.launchql()])
|
|
|
29
33
|
cn = getConnOopts(cn);
|
|
30
34
|
const config = cn.pg;
|
|
31
35
|
const connOpts = cn.db;
|
|
32
|
-
const root = getPgRootAdmin(connOpts);
|
|
36
|
+
const root = getPgRootAdmin(config, connOpts);
|
|
33
37
|
await root.createUserRole(connOpts.connection.user, connOpts.connection.password, connOpts.rootDb);
|
|
34
38
|
const admin = new DbAdmin(config, false, connOpts);
|
|
35
39
|
if (process.env.TEST_DB) {
|
|
@@ -43,7 +47,7 @@ export const getConnections = async (cn = {}, seedAdapters = [seed.launchql()])
|
|
|
43
47
|
admin.installExtensions(connOpts.extensions);
|
|
44
48
|
}
|
|
45
49
|
await admin.grantConnect(connOpts.connection.user, config.database);
|
|
46
|
-
manager = PgTestConnector.getInstance();
|
|
50
|
+
manager = PgTestConnector.getInstance(config);
|
|
47
51
|
const pg = manager.getClient(config);
|
|
48
52
|
let teardownPromise = null;
|
|
49
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.8",
|
|
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": "1323cb5f03aefde0f6e3b070ec90082fb04dbbd4"
|
|
73
73
|
}
|