@relaybus/testing 0.0.0-stage → 0.0.0
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/LICENSE +21 -0
- package/README.md +47 -2
- package/dist/index.cjs +904 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +67 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +897 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Berkcan Şavur
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @relaybus/testing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Test utilities for relaybus.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add -D @relaybus/testing vitest
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Store contract suite
|
|
10
|
+
|
|
11
|
+
Every `EventStore` must pass it unchanged against a real database:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { eventStoreContract } from '@relaybus/testing';
|
|
15
|
+
|
|
16
|
+
eventStoreContract('MyEventStore', {
|
|
17
|
+
createStore: async () => {
|
|
18
|
+
const store = new MyEventStore(await connect());
|
|
19
|
+
await store.setup();
|
|
20
|
+
return store;
|
|
21
|
+
},
|
|
22
|
+
destroyStore: async (store) => store.close(),
|
|
23
|
+
// a second instance on the same database with its own connections
|
|
24
|
+
createPeerStore: async () => new MyEventStore(await connect()),
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
It covers transactional visibility, idempotent appends, leasing and fencing,
|
|
29
|
+
retries and dead letters, release, per-key ordering in commit order, starvation,
|
|
30
|
+
purge, statistics, data fidelity and cross-instance claim races.
|
|
31
|
+
|
|
32
|
+
## FakeClock
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const clock = new FakeClock('2026-01-01T00:00:00Z');
|
|
36
|
+
const bus = new RelayBus({ store, clock });
|
|
37
|
+
clock.advance(60_000); // make retries due
|
|
38
|
+
await bus.drain();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## InMemoryTransport
|
|
42
|
+
|
|
43
|
+
Records publishes, simulates outages with `failNextPublishes(n)` and delivers
|
|
44
|
+
JSON copies to subscribers with `deliver(destination, envelope, maxRedeliveries)`.
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
MIT
|