@owlmeans/test-integration 0.1.18-rc.33 → 0.1.18-rc.34
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
CHANGED
|
@@ -1,15 +1,141 @@
|
|
|
1
1
|
# @owlmeans/test-integration
|
|
2
2
|
|
|
3
|
-
Env-gated harness for integration tests of packages that talk to external services (MongoDB, Redis, S3-compatible storage, Kubernetes). Bundles helper gates and per-run namespacing — the actual driver libraries (`mongodb`, `ioredis`, `@aws-sdk/client-s3`, `@kubernetes/client-node`) stay where they already live, in the consuming integration packages.
|
|
3
|
+
Env-gated harness for integration tests of packages that talk to external services (PostgreSQL, MongoDB, Redis, S3-compatible storage, Kubernetes, SMTP). Bundles helper gates and per-run namespacing — the actual driver libraries (`pg`, `mongodb`, `ioredis`, `@aws-sdk/client-s3`, `@kubernetes/client-node`, `nodemailer`) stay where they already live, in the consuming integration packages. It is a dev dependency of category-C packages; a package whose provider is outside these six services (an LLM provider, the Mailgun HTTP API) declares its own gate with `makeGates` from `@owlmeans/test` instead. The package's skill is `testing-integration`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
```bash
|
|
8
|
+
bun add -d @owlmeans/test-integration@^0.1.18-rc.34
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Concepts
|
|
12
|
+
|
|
13
|
+
- **Integration gate** — `IntegrationGate<E>` = `{ skip, reason?, env }`. Each gate fails closed on
|
|
14
|
+
its required variables; `env` holds only the variables that were actually populated.
|
|
15
|
+
- **Reachability probe** — the three datastore gates also require a host in the connection string
|
|
16
|
+
to accept a TCP connect. A set variable pointing at nothing (a port-forward that is not running)
|
|
17
|
+
closes the gate with a printed reason naming the variable and `host:port`. The probe is
|
|
18
|
+
synchronous, so gates are read at module scope; SRV and unix-socket addresses are not probed.
|
|
19
|
+
- **Namespace** — `randomNamespace(prefix)`, a short random suffix that keeps database names, key
|
|
20
|
+
prefixes, schemas and S3 object prefixes unique per run and per spec file.
|
|
21
|
+
- **Cleanup queue** — `cleanupHelper`, a process-global LIFO queue drained in `afterAll`; safe only
|
|
22
|
+
when a single spec file of the package provisions anything.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Gate and provision in `tests/context.ts`
|
|
27
|
+
|
|
28
|
+
Specs do not call services through these helpers — they consume the per-package real test context
|
|
29
|
+
built in `tests/context.ts` and only check the gate to self-skip when the dependency is missing.
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
// tests/context.ts
|
|
33
|
+
import { gateHelper, randomNamespace } from '@owlmeans/test-integration'
|
|
34
|
+
import type { IntegrationGate, MongoEnv } from '@owlmeans/test-integration'
|
|
35
|
+
|
|
36
|
+
export const gate: IntegrationGate<MongoEnv> = gateHelper.mongoGate()
|
|
37
|
+
|
|
38
|
+
export const makeSuite = (label: string) => {
|
|
39
|
+
// calling a gate already loaded the repo-root .env, so defaulted optionals come from process.env
|
|
40
|
+
const prefix = process.env.MONGO_TEST_DB_PREFIX ?? 'omt'
|
|
41
|
+
const database = randomNamespace(`${prefix}_${label}`)
|
|
42
|
+
const url = gate.env.MONGO_URL as string
|
|
43
|
+
|
|
44
|
+
const teardown = async (): Promise<void> => {
|
|
45
|
+
if (gate.skip) return
|
|
46
|
+
/* drop `database` with the driver this package already owns */
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { database, url, teardown }
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Self-skip a spec
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { afterAll, describe, test } from 'bun:test'
|
|
57
|
+
import { gate, makeSuite } from './context.js'
|
|
58
|
+
|
|
59
|
+
const suite = makeSuite('crud')
|
|
60
|
+
const it = gate.skip ? test.skip : test
|
|
61
|
+
|
|
62
|
+
describe('@owlmeans/mongo — crud', () => {
|
|
63
|
+
if (gate.skip) {
|
|
64
|
+
test.skip(gate.reason ?? 'mongo gate closed', () => {})
|
|
65
|
+
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
afterAll(async () => { await suite.teardown() })
|
|
70
|
+
|
|
71
|
+
it('round-trips a record through a real context', async () => {
|
|
72
|
+
/* boot, exercise, assert */
|
|
73
|
+
}, 60_000)
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### One provisioning spec file: the cleanup queue
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { afterAll } from 'bun:test'
|
|
81
|
+
import { cleanupHelper } from '@owlmeans/test-integration'
|
|
82
|
+
|
|
83
|
+
cleanupHelper.registerCleanup(async () => { await client.db(database).dropDatabase() })
|
|
84
|
+
|
|
85
|
+
afterAll(async () => { await cleanupHelper.runCleanups() }) // LIFO; a failing cleanup is logged, not raised
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## API
|
|
89
|
+
|
|
90
|
+
### Gates
|
|
91
|
+
|
|
92
|
+
| Gate | Required | Optional | Probes |
|
|
93
|
+
|---|---|---|---|
|
|
94
|
+
| `gateHelper.mongoGate()` | `MONGO_URL` | `MONGO_TEST_DB_PREFIX` | TCP, default port 27017 |
|
|
95
|
+
| `gateHelper.postgresGate()` | `POSTGRES_URL` | `POSTGRES_TEST_DB_PREFIX` | TCP, default port 5432 |
|
|
96
|
+
| `gateHelper.redisGate()` | `REDIS_URL` | `REDIS_TEST_KEY_PREFIX` | TCP, default port 6379 |
|
|
97
|
+
| `gateHelper.s3Gate()` | `S3_ENDPOINT`, `S3_KEY`, `S3_SECRET`, `S3_TEST_BUCKET` | `S3_REGION` | — |
|
|
98
|
+
| `gateHelper.kubeGate()` | `KUBE_CONFIG`, `KUBE_TEST_OK` | — | — |
|
|
99
|
+
| `gateHelper.smtpGate()` | `SMTP_HOST`, `SMTP_USER`, `SMTP_PASSWORD`, `SMTP_FROM`, `SMTP_TEST_TO` | `SMTP_PORT`, `SMTP_SECURE` | — |
|
|
100
|
+
|
|
101
|
+
The variables are documented in the workspace-root `.env.example`.
|
|
102
|
+
|
|
103
|
+
### Helpers
|
|
104
|
+
|
|
105
|
+
| Symbol | Purpose |
|
|
106
|
+
|---|---|
|
|
107
|
+
| `gateHelper` (`createGateHelper()`) | The six gates above |
|
|
108
|
+
| `randomNamespace(prefix, length?)` | `<prefix>_<hex>`; default 6 hex characters |
|
|
109
|
+
| `cleanupHelper` (`createCleanupHelper()`) | `registerCleanup(fn)`, `runCleanups()` |
|
|
110
|
+
| `mongoGate`, `redisGate`, `postgresGate`, `smtpGate`, `registerCleanup`, `runCleanups` | Deprecated wrappers over `gateHelper` / `cleanupHelper` |
|
|
111
|
+
|
|
112
|
+
### Types
|
|
113
|
+
|
|
114
|
+
| Symbol | Purpose |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `IntegrationGate<E>` | `{ skip: boolean, reason?: string, env: Partial<E> }` |
|
|
117
|
+
| `MongoEnv`, `PostgresEnv`, `RedisEnv`, `S3Env`, `KubeEnv`, `SmtpEnv` | The variable set each gate reads |
|
|
118
|
+
| `GateHelper`, `CleanupHelper`, `CleanupFn`, `ProbeTarget` | Helper interfaces and the probe's `host:port` |
|
|
119
|
+
|
|
120
|
+
## Common pitfalls
|
|
121
|
+
|
|
122
|
+
- Using the global cleanup queue from two provisioning spec files — Bun runs them in one process, so
|
|
123
|
+
the first `afterAll` drops every namespace. Give each spec file its own namespace and teardown.
|
|
124
|
+
- `skip` is a plain boolean, so `env` stays `Partial<E>` on the open branch; read a required
|
|
125
|
+
variable with a cast.
|
|
126
|
+
- Awaiting a capability probe inside the suite — Bun picks `test` / `test.skip` synchronously; probe
|
|
127
|
+
with top-level `await` in `tests/context.ts`.
|
|
128
|
+
- An open SMTP gate sends real mail to `SMTP_TEST_TO`.
|
|
129
|
+
- A reachable datastore with a wrong password still opens the gate — the probe asks for a TCP
|
|
130
|
+
connect only, never a login.
|
|
131
|
+
- Never print a credential while wiring the variables.
|
|
132
|
+
|
|
133
|
+
## Related packages
|
|
11
134
|
|
|
12
|
-
|
|
135
|
+
- [`@owlmeans/test`](../test) — env loading and `makeGates` for providers outside these six services
|
|
136
|
+
- [`@owlmeans/test-auth`](../test-auth) — auth mocks for category-B unit tests
|
|
137
|
+
- [`@owlmeans/mongo-resource`](../mongo-resource), [`@owlmeans/postgres`](../postgres), [`@owlmeans/redis`](../redis) — consumers that own their drivers
|
|
138
|
+
- [`@owlmeans/log`](../log) — the logger the skip warnings and failed cleanups go to
|
|
13
139
|
|
|
14
140
|
<!-- owlmeans:agent-guidance:start -->
|
|
15
141
|
## Agent guidance
|
|
@@ -19,7 +145,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
19
145
|
your project's skill store (`.agents/skills/`):
|
|
20
146
|
|
|
21
147
|
```sh
|
|
22
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
148
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.52
|
|
23
149
|
```
|
|
24
150
|
|
|
25
151
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/test-integration",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"version": "0.1.18-rc.34",
|
|
5
|
+
"generatedAt": "2026-10-08T21:27:54.296Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -6,7 +6,7 @@ description: Category-C integration tests for OwlMeans Common packages that talk
|
|
|
6
6
|
|
|
7
7
|
# Integration Tests — Category C
|
|
8
8
|
|
|
9
|
-
**Install:** `"@owlmeans/test-integration": "^0.1.18-rc.
|
|
9
|
+
**Install:** `"@owlmeans/test-integration": "^0.1.18-rc.34"` in `devDependencies`
|
|
10
10
|
|
|
11
11
|
Category C applies to packages that integrate with external services: `postgres`,
|
|
12
12
|
`postgres-resource`, `mongo`, `mongo-resource`, `redis`, `redis-resource`, `redis-queue`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/test-integration",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.34",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@owlmeans/log": "^0.1.18-rc.
|
|
25
|
-
"@owlmeans/test": "^0.1.18-rc.
|
|
24
|
+
"@owlmeans/log": "^0.1.18-rc.3",
|
|
25
|
+
"@owlmeans/test": "^0.1.18-rc.36"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@owlmeans/dep-config": "^0.1.18-rc.6",
|