pgsql-test 2.3.0 โ 2.3.1
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.d.ts +1 -1
- package/admin.js +4 -4
- package/connect.d.ts +2 -1
- package/connect.js +5 -4
- package/esm/admin.js +2 -2
- package/esm/connect.js +3 -2
- package/esm/manager.js +2 -2
- package/esm/seed/csv.js +1 -1
- package/esm/stream.js +1 -1
- package/manager.d.ts +1 -1
- package/manager.js +4 -4
- package/package.json +8 -6
- package/seed/csv.js +2 -2
- package/seed/types.d.ts +2 -1
- package/stream.d.ts +1 -1
- package/stream.js +2 -2
- package/test-client.d.ts +1 -1
package/admin.d.ts
CHANGED
package/admin.js
CHANGED
|
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DbAdmin = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
const
|
|
6
|
+
const pg_env_1 = require("pg-env");
|
|
7
7
|
const stream_1 = require("./stream");
|
|
8
|
-
const
|
|
9
|
-
const log = new
|
|
8
|
+
const logger_1 = require("@launchql/logger");
|
|
9
|
+
const log = new logger_1.Logger('db-admin');
|
|
10
10
|
class DbAdmin {
|
|
11
11
|
config;
|
|
12
12
|
verbose;
|
|
13
13
|
constructor(config, verbose = false) {
|
|
14
14
|
this.config = config;
|
|
15
15
|
this.verbose = verbose;
|
|
16
|
-
this.config = (0,
|
|
16
|
+
this.config = (0, pg_env_1.getPgEnvOptions)(config);
|
|
17
17
|
}
|
|
18
18
|
getEnv() {
|
|
19
19
|
return {
|
package/connect.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DbAdmin } from './admin';
|
|
2
|
-
import { PgTestConnectionOptions
|
|
2
|
+
import { PgTestConnectionOptions } from '@launchql/types';
|
|
3
|
+
import { PgConfig } from 'pg-env';
|
|
3
4
|
import { PgTestConnector } from './manager';
|
|
4
5
|
import { SeedAdapter } from './seed/types';
|
|
5
6
|
import { PgTestClient } from './test-client';
|
package/connect.js
CHANGED
|
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getConnections = exports.getPgRootAdmin = void 0;
|
|
4
4
|
const admin_1 = require("./admin");
|
|
5
5
|
const types_1 = require("@launchql/types");
|
|
6
|
+
const pg_env_1 = require("pg-env");
|
|
6
7
|
const manager_1 = require("./manager");
|
|
7
8
|
const crypto_1 = require("crypto");
|
|
8
|
-
const
|
|
9
|
+
const pg_cache_1 = require("pg-cache");
|
|
9
10
|
const seed_1 = require("./seed");
|
|
10
11
|
let manager;
|
|
11
12
|
const getPgRootAdmin = (connOpts = {}) => {
|
|
12
|
-
const opts = (0,
|
|
13
|
+
const opts = (0, pg_env_1.getPgEnvOptions)({
|
|
13
14
|
database: connOpts.rootDb
|
|
14
15
|
});
|
|
15
16
|
const admin = new admin_1.DbAdmin(opts);
|
|
@@ -18,7 +19,7 @@ const getPgRootAdmin = (connOpts = {}) => {
|
|
|
18
19
|
exports.getPgRootAdmin = getPgRootAdmin;
|
|
19
20
|
const getConnOopts = (cn = {}) => {
|
|
20
21
|
const connect = (0, types_1.getConnEnvOptions)(cn.db);
|
|
21
|
-
const config = (0,
|
|
22
|
+
const config = (0, pg_env_1.getPgEnvOptions)({
|
|
22
23
|
database: `${connect.prefix}${(0, crypto_1.randomUUID)()}`,
|
|
23
24
|
...cn.pg
|
|
24
25
|
});
|
|
@@ -64,7 +65,7 @@ const getConnections = async (cn = {}, seedAdapters = [seed_1.seed.launchql()])
|
|
|
64
65
|
});
|
|
65
66
|
db.setContext({ role: 'anonymous' });
|
|
66
67
|
const teardown = async () => {
|
|
67
|
-
await (0,
|
|
68
|
+
await (0, pg_cache_1.teardownPgPools)();
|
|
68
69
|
await manager.closeAll();
|
|
69
70
|
};
|
|
70
71
|
return { pg, db, teardown, manager, admin };
|
package/esm/admin.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { execSync } from 'child_process';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
|
-
import { getPgEnvOptions } from '
|
|
3
|
+
import { getPgEnvOptions } from 'pg-env';
|
|
4
4
|
import { streamSql as stream } from './stream';
|
|
5
|
-
import { Logger } from '@launchql/
|
|
5
|
+
import { Logger } from '@launchql/logger';
|
|
6
6
|
const log = new Logger('db-admin');
|
|
7
7
|
export class DbAdmin {
|
|
8
8
|
config;
|
package/esm/connect.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DbAdmin } from './admin';
|
|
2
|
-
import {
|
|
2
|
+
import { getConnEnvOptions } from '@launchql/types';
|
|
3
|
+
import { getPgEnvOptions, } from 'pg-env';
|
|
3
4
|
import { PgTestConnector } from './manager';
|
|
4
5
|
import { randomUUID } from 'crypto';
|
|
5
|
-
import { teardownPgPools } from '
|
|
6
|
+
import { teardownPgPools } from 'pg-cache';
|
|
6
7
|
import { seed } from './seed';
|
|
7
8
|
let manager;
|
|
8
9
|
export const getPgRootAdmin = (connOpts = {}) => {
|
package/esm/manager.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Pool } from 'pg';
|
|
2
2
|
import { DbAdmin } from './admin';
|
|
3
|
-
import { getPgEnvOptions } from '
|
|
3
|
+
import { getPgEnvOptions } from 'pg-env';
|
|
4
4
|
import { PgTestClient } from './test-client';
|
|
5
|
-
import { Logger } from '@launchql/
|
|
5
|
+
import { Logger } from '@launchql/logger';
|
|
6
6
|
const log = new Logger('test-connector');
|
|
7
7
|
const SYS_EVENTS = ['SIGTERM'];
|
|
8
8
|
const end = (pool) => {
|
package/esm/seed/csv.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createReadStream, existsSync, createWriteStream } from 'fs';
|
|
2
2
|
import { pipeline } from 'node:stream/promises';
|
|
3
3
|
import { from as copyFrom, to as copyTo } from 'pg-copy-streams';
|
|
4
|
-
import { Logger } from '@launchql/
|
|
4
|
+
import { Logger } from '@launchql/logger';
|
|
5
5
|
const log = new Logger('csv');
|
|
6
6
|
export function csv(tables) {
|
|
7
7
|
return {
|
package/esm/stream.js
CHANGED
package/manager.d.ts
CHANGED
package/manager.js
CHANGED
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PgTestConnector = void 0;
|
|
4
4
|
const pg_1 = require("pg");
|
|
5
5
|
const admin_1 = require("./admin");
|
|
6
|
-
const
|
|
6
|
+
const pg_env_1 = require("pg-env");
|
|
7
7
|
const test_client_1 = require("./test-client");
|
|
8
|
-
const
|
|
9
|
-
const log = new
|
|
8
|
+
const logger_1 = require("@launchql/logger");
|
|
9
|
+
const log = new logger_1.Logger('test-connector');
|
|
10
10
|
const SYS_EVENTS = ['SIGTERM'];
|
|
11
11
|
const end = (pool) => {
|
|
12
12
|
try {
|
|
@@ -85,7 +85,7 @@ class PgTestConnector {
|
|
|
85
85
|
log.info('๐๏ธ Dropping seen databases...');
|
|
86
86
|
await Promise.all(Array.from(this.seenDbConfigs.values()).map(async (config) => {
|
|
87
87
|
try {
|
|
88
|
-
const rootPg = (0,
|
|
88
|
+
const rootPg = (0, pg_env_1.getPgEnvOptions)();
|
|
89
89
|
const admin = new admin_1.DbAdmin({ ...config, user: rootPg.user, password: rootPg.password }, this.verbose);
|
|
90
90
|
admin.drop();
|
|
91
91
|
log.warn(`๐งจ Dropped database: ${config.database}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-test",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
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,13 +60,15 @@
|
|
|
60
60
|
"@types/pg-copy-streams": "^1.2.5"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@launchql/core": "^2.3.
|
|
64
|
-
"@launchql/server-utils": "^2.1.
|
|
65
|
-
"@launchql/types": "^2.1.
|
|
63
|
+
"@launchql/core": "^2.3.1",
|
|
64
|
+
"@launchql/server-utils": "^2.1.15",
|
|
65
|
+
"@launchql/types": "^2.1.13",
|
|
66
66
|
"chalk": "^4.1.0",
|
|
67
67
|
"deepmerge": "^4.3.1",
|
|
68
68
|
"pg": "^8.16.0",
|
|
69
|
-
"pg-
|
|
69
|
+
"pg-cache": "^1.0.1",
|
|
70
|
+
"pg-copy-streams": "^6.0.6",
|
|
71
|
+
"pg-env": "^1.0.1"
|
|
70
72
|
},
|
|
71
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "835a2e84ed84edab5bea8f5954d9dfeb657beb03"
|
|
72
74
|
}
|
package/seed/csv.js
CHANGED
|
@@ -6,8 +6,8 @@ exports.exportTableToCsv = exportTableToCsv;
|
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const promises_1 = require("node:stream/promises");
|
|
8
8
|
const pg_copy_streams_1 = require("pg-copy-streams");
|
|
9
|
-
const
|
|
10
|
-
const log = new
|
|
9
|
+
const logger_1 = require("@launchql/logger");
|
|
10
|
+
const log = new logger_1.Logger('csv');
|
|
11
11
|
function csv(tables) {
|
|
12
12
|
return {
|
|
13
13
|
async seed(ctx) {
|
package/seed/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PgTestConnectionOptions } from "@launchql/types";
|
|
2
|
+
import { PgConfig } from "pg-env";
|
|
2
3
|
import { DbAdmin } from "../admin";
|
|
3
4
|
import { PgTestClient } from "../test-client";
|
|
4
5
|
export interface SeedContext {
|
package/stream.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PgConfig } from '
|
|
1
|
+
import { PgConfig } from 'pg-env';
|
|
2
2
|
export declare function streamSql(config: PgConfig, sql: string): Promise<void>;
|
package/stream.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.streamSql = streamSql;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const stream_1 = require("stream");
|
|
6
|
-
const
|
|
6
|
+
const pg_env_1 = require("pg-env");
|
|
7
7
|
function setArgs(config) {
|
|
8
8
|
const args = [
|
|
9
9
|
'-U', config.user,
|
|
@@ -30,7 +30,7 @@ async function streamSql(config, sql) {
|
|
|
30
30
|
return new Promise((resolve, reject) => {
|
|
31
31
|
const sqlStream = stringToStream(sql);
|
|
32
32
|
const proc = (0, child_process_1.spawn)('psql', args, {
|
|
33
|
-
env: (0,
|
|
33
|
+
env: (0, pg_env_1.getSpawnEnvWithPg)(config)
|
|
34
34
|
});
|
|
35
35
|
sqlStream.pipe(proc.stdin);
|
|
36
36
|
proc.on('close', (code) => {
|
package/test-client.d.ts
CHANGED