@rotorsoft/act-tck 1.41.2 → 1.41.4
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 +49 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1098,6 +1098,7 @@ import {
|
|
|
1098
1098
|
act,
|
|
1099
1099
|
ConcurrencyError,
|
|
1100
1100
|
InMemoryCache,
|
|
1101
|
+
is_literal_source,
|
|
1101
1102
|
SNAP_EVENT as SNAP_EVENT2,
|
|
1102
1103
|
sensitive,
|
|
1103
1104
|
sleep,
|
|
@@ -1111,7 +1112,6 @@ var runStoreTck = (options) => {
|
|
|
1111
1112
|
describe8(`TCK / Store / ${options.name}`, () => {
|
|
1112
1113
|
let store;
|
|
1113
1114
|
const caps = { ...options.capabilities };
|
|
1114
|
-
const is_literal = (source) => !/[\]^$.*+?()[{}|\\]/.test(source);
|
|
1115
1115
|
const correlate = async (target = store) => {
|
|
1116
1116
|
const rows = [];
|
|
1117
1117
|
await target.query_streams(
|
|
@@ -1131,7 +1131,10 @@ var runStoreTck = (options) => {
|
|
|
1131
1131
|
(e) => {
|
|
1132
1132
|
mark = Math.max(mark, e.id);
|
|
1133
1133
|
},
|
|
1134
|
-
row.source !== void 0 ? {
|
|
1134
|
+
row.source !== void 0 ? {
|
|
1135
|
+
stream: row.source,
|
|
1136
|
+
stream_exact: is_literal_source(row.source, row.stream)
|
|
1137
|
+
} : {}
|
|
1135
1138
|
);
|
|
1136
1139
|
if (mark > row.at)
|
|
1137
1140
|
marks.push({
|
|
@@ -1263,6 +1266,41 @@ var runStoreTck = (options) => {
|
|
|
1263
1266
|
await store.commit(s, [], make_meta({ stream: s }), 0)
|
|
1264
1267
|
).toEqual([]);
|
|
1265
1268
|
});
|
|
1269
|
+
it7("takes concurrent commits, reads and writes on one instance", async () => {
|
|
1270
|
+
const x = `commit-concurrent-x-${uid()}`;
|
|
1271
|
+
const y = `commit-concurrent-y-${uid()}`;
|
|
1272
|
+
const [first, second, other, read, subscribed] = await Promise.allSettled([
|
|
1273
|
+
store.commit(
|
|
1274
|
+
x,
|
|
1275
|
+
[inc(1)],
|
|
1276
|
+
make_meta({ stream: x }),
|
|
1277
|
+
-1
|
|
1278
|
+
),
|
|
1279
|
+
store.commit(
|
|
1280
|
+
x,
|
|
1281
|
+
[inc(2)],
|
|
1282
|
+
make_meta({ stream: x }),
|
|
1283
|
+
-1
|
|
1284
|
+
),
|
|
1285
|
+
store.commit(y, [inc(1)], make_meta({ stream: y })),
|
|
1286
|
+
store.query(() => {
|
|
1287
|
+
}, { stream: x, stream_exact: true }),
|
|
1288
|
+
// A source nothing writes, so later claims never see it.
|
|
1289
|
+
store.subscribe([
|
|
1290
|
+
{ stream: `${y}-idle`, source: `${y}-no-source` }
|
|
1291
|
+
])
|
|
1292
|
+
]);
|
|
1293
|
+
expect8(
|
|
1294
|
+
[first, second].filter((r) => r.status === "fulfilled")
|
|
1295
|
+
).toHaveLength(1);
|
|
1296
|
+
const lost = [first, second].find((r) => r.status === "rejected");
|
|
1297
|
+
expect8(lost.reason).toBeInstanceOf(
|
|
1298
|
+
ConcurrencyError
|
|
1299
|
+
);
|
|
1300
|
+
expect8(other.status).toBe("fulfilled");
|
|
1301
|
+
expect8(read.status).toBe("fulfilled");
|
|
1302
|
+
expect8(subscribed.status).toBe("fulfilled");
|
|
1303
|
+
});
|
|
1266
1304
|
it7("preserves prior events when a concurrent commit is rejected", async () => {
|
|
1267
1305
|
const s = `commit-cc-preserve-${uid()}`;
|
|
1268
1306
|
await store.commit(
|
|
@@ -1850,6 +1888,16 @@ var runStoreTck = (options) => {
|
|
|
1850
1888
|
const leases = await store.claim(5, 5, `w-${uid()}`, 5e3);
|
|
1851
1889
|
expect8(leases.filter((l) => l.stream === s)).toHaveLength(0);
|
|
1852
1890
|
});
|
|
1891
|
+
it7("takes a target reading itself, whatever its name holds", async () => {
|
|
1892
|
+
const name = `self-a+b(${uid()}`;
|
|
1893
|
+
await store.subscribe([{ stream: name, source: name }]);
|
|
1894
|
+
const found = [];
|
|
1895
|
+
await store.query_streams((p) => found.push(p.stream), {
|
|
1896
|
+
stream: name,
|
|
1897
|
+
stream_exact: true
|
|
1898
|
+
});
|
|
1899
|
+
expect8(found).toEqual([name]);
|
|
1900
|
+
});
|
|
1853
1901
|
it7("claims a fresh subscription as soon as its first event is marked", async () => {
|
|
1854
1902
|
const s = `fresh-first-${uid()}`;
|
|
1855
1903
|
const src = `fresh-first-src-${uid()}`;
|