@sureq/store-test 0.0.0-stage → 1.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 +48 -2
- package/dist/index.cjs +8492 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +96 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.js +8468 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Avinash Valluru
|
|
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,49 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sureq/store-test
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Conformance suite for SureQ stores. It checks a store against the store contract: claims, leases, fencing
|
|
4
|
+
tokens, sweeping, release, cancel, pause, the store clock, and the duplicate rules (unique ids, singleton keys,
|
|
5
|
+
`seq` for idempotency keys, revision-checked writes for merges). A store that passes it is safe to put under a
|
|
6
|
+
SureQ queue.
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
npm install --save-dev @sureq/store-test @sureq/core
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Documentation
|
|
13
|
+
|
|
14
|
+
The options, the time modes, how to read a failure and the report format are in the
|
|
15
|
+
[conformance kit](https://github.com/sureq-js/sureq/blob/main/user-docs/04-stores/03-conformance-kit.md) page; the store contract and the guide to writing a
|
|
16
|
+
store are in [Stores](https://github.com/sureq-js/sureq/blob/main/user-docs/04-stores/01-store-contract.md).
|
|
17
|
+
|
|
18
|
+
## Use
|
|
19
|
+
|
|
20
|
+
Call `runStoreConformance` from a test file. It registers the tests with your test runner (node:test, Vitest
|
|
21
|
+
with `globals: true`, or Jest are detected; otherwise pass `runner`).
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import type { Store } from '@sureq/core';
|
|
25
|
+
import { runStoreConformance } from '@sureq/store-test';
|
|
26
|
+
|
|
27
|
+
// Stand-in for your adapter; yours comes from your own package.
|
|
28
|
+
declare function createMyStore(opts: { prefix: string; clock?: () => number }): Store;
|
|
29
|
+
|
|
30
|
+
runStoreConformance({
|
|
31
|
+
name: 'my-store',
|
|
32
|
+
createStore: async (ctx) => {
|
|
33
|
+
const store = createMyStore({ prefix: ctx.scopeId, ...(ctx.clock && { clock: () => ctx.clock!.now() }) });
|
|
34
|
+
await store.open();
|
|
35
|
+
return { store, cleanup: () => store.close() };
|
|
36
|
+
},
|
|
37
|
+
report: './conformance-report.json',
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The report's `conformant` is `true` only when nothing failed and no required group was skipped. Raise your
|
|
42
|
+
runner's test timeout for the long tests (for Vitest, `testTimeout: 600_000`).
|
|
43
|
+
|
|
44
|
+
## Writing an adapter
|
|
45
|
+
|
|
46
|
+
The step-by-step guide is [Writing your own store](https://github.com/sureq-js/sureq/blob/main/user-docs/04-stores/02-writing-your-own.md): the six
|
|
47
|
+
primitives, the build order, an atomicity checklist for every method, the common mistakes and the test that catches
|
|
48
|
+
each, and publishing. The finished example is [`examples/store-template`](https://github.com/sureq-js/sureq/blob/main/examples/store-template/README.md),
|
|
49
|
+
a commented store that passes the whole suite.
|