pgsql-test 2.0.5 → 2.0.6
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 +23 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -79,6 +79,16 @@ afterAll(() => teardown());
|
|
|
79
79
|
|
|
80
80
|
## `getConnections()` Overview
|
|
81
81
|
|
|
82
|
+
```ts
|
|
83
|
+
import { getConnections } from 'pgsql-test';
|
|
84
|
+
|
|
85
|
+
// Complete object destructuring
|
|
86
|
+
const { pg, db, admin, teardown, manager } = await getConnections();
|
|
87
|
+
|
|
88
|
+
// Most common pattern
|
|
89
|
+
const { db, teardown } = await getConnections();
|
|
90
|
+
```
|
|
91
|
+
|
|
82
92
|
The `getConnections()` helper sets up a fresh PostgreSQL test database and returns a structured object with:
|
|
83
93
|
|
|
84
94
|
* `pg`: a `PgTestClient` connected as the root or superuser — useful for administrative setup or introspection
|
|
@@ -97,6 +107,19 @@ The `PgTestClient` returned by `getConnections()` is a fully-featured wrapper ar
|
|
|
97
107
|
|
|
98
108
|
## `PgTestClient` API Overview
|
|
99
109
|
|
|
110
|
+
```ts
|
|
111
|
+
let pg: PgTestClient;
|
|
112
|
+
let teardown: () => Promise<void>;
|
|
113
|
+
|
|
114
|
+
beforeAll(async () => {
|
|
115
|
+
({ pg, teardown } = await getConnections());
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
beforeEach(() => pg.beforeEach());
|
|
119
|
+
afterEach(() => pg.afterEach());
|
|
120
|
+
afterAll(() => teardown());
|
|
121
|
+
```
|
|
122
|
+
|
|
100
123
|
The `PgTestClient` returned by `getConnections()` wraps a `pg.Client` and provides convenient helpers for query execution, test isolation, and context switching.
|
|
101
124
|
|
|
102
125
|
### Common Methods
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-test",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
5
|
"description": "PostgreSQL Testing in TypeScript",
|
|
6
6
|
"main": "index.js",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"pg": "^8.16.0",
|
|
43
43
|
"pg-copy-streams": "^6.0.6"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "9ca7885acaf53b419b6c589f739011e047dd6954"
|
|
46
46
|
}
|