pgsql-test 2.0.3 → 2.0.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/README.md +43 -15
- package/connect.d.ts +3 -3
- package/connect.js +1 -1
- package/esm/connect.js +1 -1
- package/package.json +5 -5
- package/seed/types.d.ts +2 -2
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Part of the [LaunchQL](https://github.com/launchql) ecosystem, `pgsql-test` is b
|
|
|
47
47
|
1. [Install](#install)
|
|
48
48
|
2. [Features](#features)
|
|
49
49
|
3. [Quick Start](#-quick-start)
|
|
50
|
-
4. [getConnections() Overview](#getconnections-overview)
|
|
50
|
+
4. [`getConnections()` Overview](#getconnections-overview)
|
|
51
51
|
5. [PgTestClient API Overview](#pgtestclient-api-overview)
|
|
52
52
|
6. [Usage Examples](#usage-examples)
|
|
53
53
|
* [Basic Setup](#-basic-setup)
|
|
@@ -58,7 +58,7 @@ Part of the [LaunchQL](https://github.com/launchql) ecosystem, `pgsql-test` is b
|
|
|
58
58
|
* [JSON Seeding](#️-json-seeding)
|
|
59
59
|
* [Sqitch Seeding](#️-sqitch-seeding)
|
|
60
60
|
* [LaunchQL Seeding](#-launchql-seeding)
|
|
61
|
-
7. [
|
|
61
|
+
7. [`getConnections() Options` ](#getconnections-options)
|
|
62
62
|
8. [Disclaimer](#disclaimer)
|
|
63
63
|
|
|
64
64
|
|
|
@@ -379,23 +379,51 @@ LaunchQL provides the best of both worlds:
|
|
|
379
379
|
|
|
380
380
|
By maintaining Sqitch compatibility while supercharging performance, LaunchQL enables you to keep your existing migration patterns while enjoying the speed benefits of our TypeScript engine.
|
|
381
381
|
|
|
382
|
-
##
|
|
382
|
+
## `getConnections` Options
|
|
383
383
|
|
|
384
|
-
`
|
|
384
|
+
This table documents the available options for the `getConnections` function. The options are passed as a combination of `pg` and `db` configuration objects.
|
|
385
385
|
|
|
386
|
-
|
|
387
|
-
* `PGPORT`
|
|
388
|
-
* `PGUSER`
|
|
389
|
-
* `PGPASSWORD`
|
|
386
|
+
### `db` Options (PgTestConnectionOptions)
|
|
390
387
|
|
|
391
|
-
|
|
388
|
+
| Option | Type | Default | Description |
|
|
389
|
+
| ------------------------ | ---------- | ---------------- | --------------------------------------------------------------------------- |
|
|
390
|
+
| `db.extensions` | `string[]` | `[]` | Array of PostgreSQL extensions to include in the test database |
|
|
391
|
+
| `db.cwd` | `string` | `process.cwd()` | Working directory used for LaunchQL/Sqitch projects |
|
|
392
|
+
| `db.connection.user` | `string` | `'app_user'` | User for simulating RLS via `setContext()` |
|
|
393
|
+
| `db.connection.password` | `string` | `'app_password'` | Password for RLS test user |
|
|
394
|
+
| `db.connection.role` | `string` | `'anonymous'` | Default role used during `setContext()` |
|
|
395
|
+
| `db.template` | `string` | `undefined` | Template database used for faster test DB creation |
|
|
396
|
+
| `db.rootDb` | `string` | `'postgres'` | Root database used for administrative operations (e.g., creating databases) |
|
|
397
|
+
| `db.prefix` | `string` | `'db-'` | Prefix used when generating test database names |
|
|
392
398
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
+
### `pg` Options (PgConfig)
|
|
400
|
+
|
|
401
|
+
Environment variables will override these options when available:
|
|
402
|
+
|
|
403
|
+
* `PGHOST`, `PGPORT`, `PGUSER`, `PGPASSWORD`, `PGDATABASE`
|
|
404
|
+
|
|
405
|
+
| Option | Type | Default | Description |
|
|
406
|
+
| ------------- | -------- | ------------- | ----------------------------------------------- |
|
|
407
|
+
| `pg.user` | `string` | `'postgres'` | Superuser for PostgreSQL |
|
|
408
|
+
| `pg.password` | `string` | `'password'` | Password for the PostgreSQL superuser |
|
|
409
|
+
| `pg.host` | `string` | `'localhost'` | Hostname for PostgreSQL |
|
|
410
|
+
| `pg.port` | `number` | `5423` | Port for PostgreSQL |
|
|
411
|
+
| `pg.database` | `string` | `'postgres'` | Default database used when connecting initially |
|
|
412
|
+
|
|
413
|
+
### Usage
|
|
414
|
+
|
|
415
|
+
```ts
|
|
416
|
+
const { conn, db, teardown } = await getConnections({
|
|
417
|
+
pg: { user: 'postgres', password: 'secret' },
|
|
418
|
+
db: {
|
|
419
|
+
extensions: ['uuid-ossp'],
|
|
420
|
+
cwd: '/path/to/project',
|
|
421
|
+
connection: { user: 'test_user', password: 'secret', role: 'authenticated' },
|
|
422
|
+
template: 'test_template',
|
|
423
|
+
prefix: 'test_',
|
|
424
|
+
rootDb: 'postgres'
|
|
425
|
+
}
|
|
426
|
+
});
|
|
399
427
|
```
|
|
400
428
|
|
|
401
429
|
## Disclaimer
|
package/connect.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DbAdmin } from './admin';
|
|
2
|
-
import {
|
|
2
|
+
import { PgTestConnectionOptions, PgConfig } from '@launchql/types';
|
|
3
3
|
import { PgTestConnector } from './manager';
|
|
4
4
|
import { SeedAdapter } from './seed/types';
|
|
5
5
|
import { PgTestClient } from './test-client';
|
|
6
|
-
export declare const getPgRootAdmin: (connOpts?:
|
|
6
|
+
export declare const getPgRootAdmin: (connOpts?: PgTestConnectionOptions) => DbAdmin;
|
|
7
7
|
export interface GetConnectionOpts {
|
|
8
8
|
pg?: Partial<PgConfig>;
|
|
9
|
-
db?: Partial<
|
|
9
|
+
db?: Partial<PgTestConnectionOptions>;
|
|
10
10
|
}
|
|
11
11
|
export interface GetConnectionResult {
|
|
12
12
|
pg: PgTestClient;
|
package/connect.js
CHANGED
|
@@ -27,7 +27,7 @@ const getConnOopts = (cn = {}) => {
|
|
|
27
27
|
db: connect
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
const getConnections = async (cn = {}, seedAdapters = []) => {
|
|
30
|
+
const getConnections = async (cn = {}, seedAdapters = [seed_1.seed.launchql()]) => {
|
|
31
31
|
cn = getConnOopts(cn);
|
|
32
32
|
const config = cn.pg;
|
|
33
33
|
const connOpts = cn.db;
|
package/esm/connect.js
CHANGED
|
@@ -23,7 +23,7 @@ const getConnOopts = (cn = {}) => {
|
|
|
23
23
|
db: connect
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
export const getConnections = async (cn = {}, seedAdapters = []) => {
|
|
26
|
+
export const getConnections = async (cn = {}, seedAdapters = [seed.launchql()]) => {
|
|
27
27
|
cn = getConnOopts(cn);
|
|
28
28
|
const config = cn.pg;
|
|
29
29
|
const connOpts = cn.db;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-test",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
5
|
"description": "PostgreSQL Testing in TypeScript",
|
|
6
6
|
"main": "index.js",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"@types/pg-copy-streams": "^1.2.5"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@launchql/migrate": "^2.0.
|
|
38
|
-
"@launchql/server-utils": "^2.0.
|
|
39
|
-
"@launchql/types": "^2.0.
|
|
37
|
+
"@launchql/migrate": "^2.0.14",
|
|
38
|
+
"@launchql/server-utils": "^2.0.7",
|
|
39
|
+
"@launchql/types": "^2.0.6",
|
|
40
40
|
"chalk": "^4.1.0",
|
|
41
41
|
"deepmerge": "^4.3.1",
|
|
42
42
|
"pg": "^8.16.0",
|
|
43
43
|
"pg-copy-streams": "^6.0.6"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "b347f01f28aa33c195f78d911eab8757777b0c88"
|
|
46
46
|
}
|
package/seed/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PgConfig,
|
|
1
|
+
import { PgConfig, PgTestConnectionOptions } from "@launchql/types";
|
|
2
2
|
import { DbAdmin } from "../admin";
|
|
3
3
|
import { PgTestClient } from "../test-client";
|
|
4
4
|
export interface SeedContext {
|
|
5
|
-
connect:
|
|
5
|
+
connect: PgTestConnectionOptions;
|
|
6
6
|
admin: DbAdmin;
|
|
7
7
|
config: PgConfig;
|
|
8
8
|
pg: PgTestClient;
|