@rotorsoft/act-tck 1.30.0 → 1.30.2
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 +70 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +70 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1691,6 +1691,74 @@ var runStoreTck = (options) => {
|
|
|
1691
1691
|
await store.subscribe([{ stream: s }]);
|
|
1692
1692
|
expect8(await read()).toBe(10);
|
|
1693
1693
|
});
|
|
1694
|
+
it7("does not claim a fresh subscription with no matching events", async () => {
|
|
1695
|
+
const s = `fresh-empty-${uid()}`;
|
|
1696
|
+
const src = `fresh-src-${uid()}`;
|
|
1697
|
+
await store.subscribe([{ stream: s, source: src }]);
|
|
1698
|
+
const leases = await store.claim(5, 5, `w-${uid()}`, 5e3);
|
|
1699
|
+
expect8(leases.filter((l) => l.stream === s)).toHaveLength(0);
|
|
1700
|
+
});
|
|
1701
|
+
it7("claims a fresh subscription as soon as its first event lands", async () => {
|
|
1702
|
+
const s = `fresh-first-${uid()}`;
|
|
1703
|
+
const src = `fresh-first-src-${uid()}`;
|
|
1704
|
+
await store.subscribe([{ stream: s, source: src }]);
|
|
1705
|
+
await store.commit(
|
|
1706
|
+
src,
|
|
1707
|
+
[inc(1)],
|
|
1708
|
+
make_meta({ stream: src })
|
|
1709
|
+
);
|
|
1710
|
+
const leases = await store.claim(5, 5, `w-${uid()}`, 5e3);
|
|
1711
|
+
const mine = leases.filter((l) => l.stream === s);
|
|
1712
|
+
expect8(mine).toHaveLength(1);
|
|
1713
|
+
expect8(mine[0].at).toBe(-1);
|
|
1714
|
+
const in_window = [];
|
|
1715
|
+
await store.query((e) => in_window.push(e), {
|
|
1716
|
+
stream: src,
|
|
1717
|
+
stream_exact: true,
|
|
1718
|
+
after: mine[0].at
|
|
1719
|
+
});
|
|
1720
|
+
expect8(in_window).toHaveLength(1);
|
|
1721
|
+
});
|
|
1722
|
+
it7("keeps the maximum for negative and zero priorities too", async () => {
|
|
1723
|
+
const s = `sub-pri-neg-${uid()}`;
|
|
1724
|
+
const read = async () => {
|
|
1725
|
+
const got = {};
|
|
1726
|
+
await store.query_streams(
|
|
1727
|
+
(p) => {
|
|
1728
|
+
got.priority = p.priority;
|
|
1729
|
+
},
|
|
1730
|
+
{ stream: s, stream_exact: true }
|
|
1731
|
+
);
|
|
1732
|
+
return got.priority;
|
|
1733
|
+
};
|
|
1734
|
+
await store.subscribe([{ stream: s, priority: -5 }]);
|
|
1735
|
+
expect8(await read()).toBe(-5);
|
|
1736
|
+
await store.subscribe([{ stream: s, priority: -1 }]);
|
|
1737
|
+
expect8(await read()).toBe(-1);
|
|
1738
|
+
await store.subscribe([{ stream: s, priority: -9 }]);
|
|
1739
|
+
expect8(await read()).toBe(-1);
|
|
1740
|
+
await store.subscribe([{ stream: s }]);
|
|
1741
|
+
expect8(await read()).toBe(0);
|
|
1742
|
+
});
|
|
1743
|
+
it7("restores the declared priority on the next subscribe after a prioritize() downgrade", async () => {
|
|
1744
|
+
const s = `sub-pri-restore-${uid()}`;
|
|
1745
|
+
const read = async () => {
|
|
1746
|
+
const got = {};
|
|
1747
|
+
await store.query_streams(
|
|
1748
|
+
(p) => {
|
|
1749
|
+
got.priority = p.priority;
|
|
1750
|
+
},
|
|
1751
|
+
{ stream: s, stream_exact: true }
|
|
1752
|
+
);
|
|
1753
|
+
return got.priority;
|
|
1754
|
+
};
|
|
1755
|
+
await store.subscribe([{ stream: s }]);
|
|
1756
|
+
expect8(await read()).toBe(0);
|
|
1757
|
+
await store.prioritize({ stream: s, stream_exact: true }, -5);
|
|
1758
|
+
expect8(await read()).toBe(-5);
|
|
1759
|
+
await store.subscribe([{ stream: s }]);
|
|
1760
|
+
expect8(await read()).toBe(0);
|
|
1761
|
+
});
|
|
1694
1762
|
it7("claims a subscribed stream and ack releases the lease", async () => {
|
|
1695
1763
|
const s = `claim-${uid()}`;
|
|
1696
1764
|
await store.subscribe([{ stream: s }]);
|
|
@@ -2089,12 +2157,8 @@ var runStoreTck = (options) => {
|
|
|
2089
2157
|
const first = await fresh.claim(100, 0, `w-${uid()}`, 3e4);
|
|
2090
2158
|
const l1 = first.find((s) => s.stream === target);
|
|
2091
2159
|
expect8(l1).toBeDefined();
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
await fresh.ack([
|
|
2095
|
-
{ ...l1, at: ea.id },
|
|
2096
|
-
{ ...c1, at: -1 }
|
|
2097
|
-
]);
|
|
2160
|
+
expect8(first.map((s) => s.stream)).not.toContain(control);
|
|
2161
|
+
await fresh.ack([{ ...l1, at: ea.id }]);
|
|
2098
2162
|
await seed_stream(fresh, other, 1);
|
|
2099
2163
|
const claimed = await fresh.claim(100, 0, `w-${uid()}`, 3e4);
|
|
2100
2164
|
const streams = claimed.map((s) => s.stream);
|