pgsql-test 4.13.1 → 4.13.2
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 +13 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -191,7 +191,19 @@ db.setContext({
|
|
|
191
191
|
});
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
-
This applies the settings using `SET LOCAL` statements, ensuring they persist only for the current transaction and maintain proper isolation between tests.
|
|
194
|
+
This applies the settings using `SET LOCAL` and `set_config(..., true)` statements, ensuring they persist only for the current transaction and maintain proper isolation between tests.
|
|
195
|
+
|
|
196
|
+
> **⚠️ Important:** `set_config(..., true)` is **transaction-local**. Inside test bodies (`it()` blocks), `beforeEach()` has already started a transaction, so context persists across queries automatically. However, in `beforeAll()` there is no active transaction — each query runs in auto-commit mode and context is lost between calls. If you need context-aware operations in `beforeAll()`, wrap them in explicit `db.begin()` / `db.commit()`:
|
|
197
|
+
>
|
|
198
|
+
> ```ts
|
|
199
|
+
> beforeAll(async () => {
|
|
200
|
+
> ({ db, teardown } = await getConnections());
|
|
201
|
+
> await db.begin();
|
|
202
|
+
> db.setContext({ role: 'authenticated', 'jwt.claims.user_id': '123' });
|
|
203
|
+
> await db.query('SELECT current_user_id()'); // context persists within transaction
|
|
204
|
+
> await db.commit();
|
|
205
|
+
> });
|
|
206
|
+
> ```
|
|
195
207
|
|
|
196
208
|
#### Testing Role-Based Access
|
|
197
209
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-test",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.2",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
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",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"pgsql-client": "^3.13.1",
|
|
72
72
|
"pgsql-seed": "^2.13.1"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "ea590e1b9e1ee38c267f8dbbb37aa3f83a5d3fb7"
|
|
75
75
|
}
|