@rotorsoft/act-tck 1.41.1 → 1.41.3
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/dist/.tsbuildinfo +1 -1
- package/dist/@types/store-tck.d.ts.map +1 -1
- package/dist/index.cjs +48 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1236,6 +1236,19 @@ var runStoreTck = (options) => {
|
|
|
1236
1236
|
store.commit(s, [inc(1)], make_meta({ stream: s }), 0)
|
|
1237
1237
|
).rejects.toBeInstanceOf(ConcurrencyError);
|
|
1238
1238
|
});
|
|
1239
|
+
it7("treats expectedVersion -1 as an empty stream", async () => {
|
|
1240
|
+
const s = `commit-new-cc-${uid()}`;
|
|
1241
|
+
const [first] = await store.commit(
|
|
1242
|
+
s,
|
|
1243
|
+
[inc(1)],
|
|
1244
|
+
make_meta({ stream: s }),
|
|
1245
|
+
-1
|
|
1246
|
+
);
|
|
1247
|
+
expect8(first.version).toBe(0);
|
|
1248
|
+
await expect8(
|
|
1249
|
+
store.commit(s, [inc(1)], make_meta({ stream: s }), -1)
|
|
1250
|
+
).rejects.toBeInstanceOf(ConcurrencyError);
|
|
1251
|
+
});
|
|
1239
1252
|
it7("checks expectedVersion even when committing no events", async () => {
|
|
1240
1253
|
const s = `commit-empty-cc-${uid()}`;
|
|
1241
1254
|
await store.commit(
|
|
@@ -1250,6 +1263,41 @@ var runStoreTck = (options) => {
|
|
|
1250
1263
|
await store.commit(s, [], make_meta({ stream: s }), 0)
|
|
1251
1264
|
).toEqual([]);
|
|
1252
1265
|
});
|
|
1266
|
+
it7("takes concurrent commits, reads and writes on one instance", async () => {
|
|
1267
|
+
const x = `commit-concurrent-x-${uid()}`;
|
|
1268
|
+
const y = `commit-concurrent-y-${uid()}`;
|
|
1269
|
+
const [first, second, other, read, subscribed] = await Promise.allSettled([
|
|
1270
|
+
store.commit(
|
|
1271
|
+
x,
|
|
1272
|
+
[inc(1)],
|
|
1273
|
+
make_meta({ stream: x }),
|
|
1274
|
+
-1
|
|
1275
|
+
),
|
|
1276
|
+
store.commit(
|
|
1277
|
+
x,
|
|
1278
|
+
[inc(2)],
|
|
1279
|
+
make_meta({ stream: x }),
|
|
1280
|
+
-1
|
|
1281
|
+
),
|
|
1282
|
+
store.commit(y, [inc(1)], make_meta({ stream: y })),
|
|
1283
|
+
store.query(() => {
|
|
1284
|
+
}, { stream: x, stream_exact: true }),
|
|
1285
|
+
// A source nothing writes, so later claims never see it.
|
|
1286
|
+
store.subscribe([
|
|
1287
|
+
{ stream: `${y}-idle`, source: `${y}-no-source` }
|
|
1288
|
+
])
|
|
1289
|
+
]);
|
|
1290
|
+
expect8(
|
|
1291
|
+
[first, second].filter((r) => r.status === "fulfilled")
|
|
1292
|
+
).toHaveLength(1);
|
|
1293
|
+
const lost = [first, second].find((r) => r.status === "rejected");
|
|
1294
|
+
expect8(lost.reason).toBeInstanceOf(
|
|
1295
|
+
ConcurrencyError
|
|
1296
|
+
);
|
|
1297
|
+
expect8(other.status).toBe("fulfilled");
|
|
1298
|
+
expect8(read.status).toBe("fulfilled");
|
|
1299
|
+
expect8(subscribed.status).toBe("fulfilled");
|
|
1300
|
+
});
|
|
1253
1301
|
it7("preserves prior events when a concurrent commit is rejected", async () => {
|
|
1254
1302
|
const s = `commit-cc-preserve-${uid()}`;
|
|
1255
1303
|
await store.commit(
|