@rotorsoft/act-tck 0.2.0 → 0.4.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/README.md +56 -59
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/store-tck.d.ts.map +1 -1
- package/dist/index.cjs +394 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +395 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -189,7 +189,7 @@ var runLoggerTck = (options) => {
|
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
// src/store-tck.ts
|
|
192
|
-
import { ConcurrencyError } from "@rotorsoft/act";
|
|
192
|
+
import { ConcurrencyError, SNAP_EVENT, TOMBSTONE_EVENT } from "@rotorsoft/act";
|
|
193
193
|
import { afterAll, beforeAll, describe as describe3, expect as expect3, it as it3 } from "vitest";
|
|
194
194
|
var runStoreTck = (options) => {
|
|
195
195
|
describe3(`TCK / Store / ${options.name}`, () => {
|
|
@@ -311,6 +311,14 @@ var runStoreTck = (options) => {
|
|
|
311
311
|
expect3(backward.map((e) => e.id)).toEqual(
|
|
312
312
|
[...committed].reverse().map((c) => c.id)
|
|
313
313
|
);
|
|
314
|
+
const latest = await collect(store, {
|
|
315
|
+
stream: s,
|
|
316
|
+
stream_exact: true,
|
|
317
|
+
backward: true,
|
|
318
|
+
limit: 1
|
|
319
|
+
});
|
|
320
|
+
expect3(latest).toHaveLength(1);
|
|
321
|
+
expect3(latest[0].id).toBe(committed.at(-1).id);
|
|
314
322
|
});
|
|
315
323
|
it3("after/before bound the id range", async () => {
|
|
316
324
|
const s = `q-bounds-${uid()}`;
|
|
@@ -867,6 +875,169 @@ var runStoreTck = (options) => {
|
|
|
867
875
|
expect3(got2.priority).toBe(5);
|
|
868
876
|
});
|
|
869
877
|
});
|
|
878
|
+
describe3("lanes", () => {
|
|
879
|
+
it3("subscribe defaults lane to 'default' when omitted", async () => {
|
|
880
|
+
const s = `lane-default-${uid()}`;
|
|
881
|
+
await store.subscribe([{ stream: s }]);
|
|
882
|
+
const seen = [];
|
|
883
|
+
await store.query_streams((p) => seen.push(p.lane), {
|
|
884
|
+
stream: s,
|
|
885
|
+
stream_exact: true
|
|
886
|
+
});
|
|
887
|
+
expect3(seen).toEqual(["default"]);
|
|
888
|
+
});
|
|
889
|
+
it3("subscribe records the lane passed in", async () => {
|
|
890
|
+
const s = `lane-set-${uid()}`;
|
|
891
|
+
await store.subscribe([{ stream: s, lane: "slow" }]);
|
|
892
|
+
const seen = [];
|
|
893
|
+
await store.query_streams((p) => seen.push(p.lane), {
|
|
894
|
+
stream: s,
|
|
895
|
+
stream_exact: true
|
|
896
|
+
});
|
|
897
|
+
expect3(seen).toEqual(["slow"]);
|
|
898
|
+
});
|
|
899
|
+
it3("subscribe re-lanes existing streams on subsequent calls", async () => {
|
|
900
|
+
const s = `lane-upsert-${uid()}`;
|
|
901
|
+
await store.subscribe([{ stream: s, lane: "slow" }]);
|
|
902
|
+
await store.subscribe([{ stream: s, lane: "fast" }]);
|
|
903
|
+
const seen = [];
|
|
904
|
+
await store.query_streams((p) => seen.push(p.lane), {
|
|
905
|
+
stream: s,
|
|
906
|
+
stream_exact: true
|
|
907
|
+
});
|
|
908
|
+
expect3(seen).toEqual(["fast"]);
|
|
909
|
+
});
|
|
910
|
+
it3("claim() filters by lane when supplied and returns lane on the Lease", async () => {
|
|
911
|
+
const tag = uid();
|
|
912
|
+
const src1 = `lane-claim-src1-${tag}`;
|
|
913
|
+
const src2 = `lane-claim-src2-${tag}`;
|
|
914
|
+
const subDefault = `lane-claim-def-${tag}`;
|
|
915
|
+
const subSlow = `lane-claim-slow-${tag}`;
|
|
916
|
+
await store.commit(
|
|
917
|
+
src1,
|
|
918
|
+
[inc(1)],
|
|
919
|
+
makeMeta({ stream: src1 })
|
|
920
|
+
);
|
|
921
|
+
await store.commit(
|
|
922
|
+
src2,
|
|
923
|
+
[inc(1)],
|
|
924
|
+
makeMeta({ stream: src2 })
|
|
925
|
+
);
|
|
926
|
+
await store.subscribe([
|
|
927
|
+
{ stream: subDefault, source: src1 },
|
|
928
|
+
{ stream: subSlow, source: src2, lane: "slow" }
|
|
929
|
+
]);
|
|
930
|
+
const slow = await store.claim(50, 0, `w-slow-${tag}`, 1e3, "slow");
|
|
931
|
+
const slowMine = slow.filter(
|
|
932
|
+
(l) => l.stream === subDefault || l.stream === subSlow
|
|
933
|
+
);
|
|
934
|
+
expect3(slowMine.map((l) => l.stream)).toEqual([subSlow]);
|
|
935
|
+
expect3(slowMine[0]?.lane).toBe("slow");
|
|
936
|
+
await store.ack(slowMine.map((l) => ({ ...l, at: l.at + 1 })));
|
|
937
|
+
const all = await store.claim(50, 0, `w-all-${tag}`, 1e3);
|
|
938
|
+
const allMine = all.filter((l) => l.stream === subDefault || l.stream === subSlow).map((l) => ({ stream: l.stream, lane: l.lane }));
|
|
939
|
+
expect3(allMine).toEqual(
|
|
940
|
+
expect3.arrayContaining([
|
|
941
|
+
{ stream: subDefault, lane: "default" },
|
|
942
|
+
{ stream: subSlow, lane: "slow" }
|
|
943
|
+
])
|
|
944
|
+
);
|
|
945
|
+
});
|
|
946
|
+
it3("query_streams filters by lane", async () => {
|
|
947
|
+
const tag = uid();
|
|
948
|
+
const a = `lane-q-a-${tag}`;
|
|
949
|
+
const b = `lane-q-b-${tag}`;
|
|
950
|
+
const c = `lane-q-c-${tag}`;
|
|
951
|
+
await store.subscribe([
|
|
952
|
+
{ stream: a, lane: "qslow" },
|
|
953
|
+
{ stream: b, lane: "qfast" },
|
|
954
|
+
{ stream: c, lane: "qslow" }
|
|
955
|
+
]);
|
|
956
|
+
const seen = [];
|
|
957
|
+
await store.query_streams((p) => seen.push(p.stream), {
|
|
958
|
+
lane: "qslow",
|
|
959
|
+
stream: `lane-q-.*-${tag}`,
|
|
960
|
+
limit: 100
|
|
961
|
+
});
|
|
962
|
+
expect3(seen.sort()).toEqual([a, c]);
|
|
963
|
+
});
|
|
964
|
+
it3("prioritize filters by lane", async () => {
|
|
965
|
+
const tag = uid();
|
|
966
|
+
const a = `lane-pri-a-${tag}`;
|
|
967
|
+
const b = `lane-pri-b-${tag}`;
|
|
968
|
+
await store.subscribe([
|
|
969
|
+
{ stream: a, lane: `pslow-${tag}` },
|
|
970
|
+
{ stream: b, lane: `pfast-${tag}` }
|
|
971
|
+
]);
|
|
972
|
+
const updated = await store.prioritize({ lane: `pslow-${tag}` }, 7);
|
|
973
|
+
expect3(updated).toBe(1);
|
|
974
|
+
const seen = /* @__PURE__ */ new Map();
|
|
975
|
+
await store.query_streams((p) => seen.set(p.stream, p.priority), {
|
|
976
|
+
stream: `lane-pri-.*-${tag}`,
|
|
977
|
+
limit: 100
|
|
978
|
+
});
|
|
979
|
+
expect3(seen.get(a)).toBe(7);
|
|
980
|
+
expect3(seen.get(b)).toBe(0);
|
|
981
|
+
});
|
|
982
|
+
it3("reset filters by lane", async () => {
|
|
983
|
+
const tag = uid();
|
|
984
|
+
const src = `lane-reset-src-${tag}`;
|
|
985
|
+
const a = `lane-reset-a-${tag}`;
|
|
986
|
+
const b = `lane-reset-b-${tag}`;
|
|
987
|
+
await store.commit(
|
|
988
|
+
src,
|
|
989
|
+
[inc(1)],
|
|
990
|
+
makeMeta({ stream: src })
|
|
991
|
+
);
|
|
992
|
+
await store.subscribe([
|
|
993
|
+
{ stream: a, source: src, lane: `rslow-${tag}` },
|
|
994
|
+
{ stream: b, source: src, lane: `rfast-${tag}` }
|
|
995
|
+
]);
|
|
996
|
+
const leases = await store.claim(50, 0, `w-${tag}`, 5e3);
|
|
997
|
+
const mine = leases.filter((l) => l.stream === a || l.stream === b);
|
|
998
|
+
await store.ack(mine.map((l) => ({ ...l, at: l.at + 1 })));
|
|
999
|
+
const count = await store.reset({ lane: `rslow-${tag}` });
|
|
1000
|
+
expect3(count).toBe(1);
|
|
1001
|
+
const ats = /* @__PURE__ */ new Map();
|
|
1002
|
+
for (const name of [a, b]) {
|
|
1003
|
+
await store.query_streams((p) => ats.set(p.stream, p.at), {
|
|
1004
|
+
stream: name,
|
|
1005
|
+
stream_exact: true
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
expect3(ats.get(a)).toBe(-1);
|
|
1009
|
+
expect3(ats.get(b)).toBeGreaterThanOrEqual(0);
|
|
1010
|
+
});
|
|
1011
|
+
it3("unblock filters by lane", async () => {
|
|
1012
|
+
const tag = uid();
|
|
1013
|
+
const src = `lane-ub-src-${tag}`;
|
|
1014
|
+
const a = `lane-ub-a-${tag}`;
|
|
1015
|
+
const b = `lane-ub-b-${tag}`;
|
|
1016
|
+
await store.commit(
|
|
1017
|
+
src,
|
|
1018
|
+
[inc(1)],
|
|
1019
|
+
makeMeta({ stream: src })
|
|
1020
|
+
);
|
|
1021
|
+
await store.subscribe([
|
|
1022
|
+
{ stream: a, source: src, lane: `uslow-${tag}` },
|
|
1023
|
+
{ stream: b, source: src, lane: `ufast-${tag}` }
|
|
1024
|
+
]);
|
|
1025
|
+
const leases = await store.claim(50, 0, `w-${tag}`, 5e3);
|
|
1026
|
+
const mine = leases.filter((l) => l.stream === a || l.stream === b);
|
|
1027
|
+
await store.block(mine.map((l) => ({ ...l, error: "boom" })));
|
|
1028
|
+
const count = await store.unblock({ lane: `uslow-${tag}` });
|
|
1029
|
+
expect3(count).toBe(1);
|
|
1030
|
+
const blocked = /* @__PURE__ */ new Map();
|
|
1031
|
+
for (const name of [a, b]) {
|
|
1032
|
+
await store.query_streams((p) => blocked.set(p.stream, p.blocked), {
|
|
1033
|
+
stream: name,
|
|
1034
|
+
stream_exact: true
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
expect3(blocked.get(a)).toBe(false);
|
|
1038
|
+
expect3(blocked.get(b)).toBe(true);
|
|
1039
|
+
});
|
|
1040
|
+
});
|
|
870
1041
|
describe3("truncate", () => {
|
|
871
1042
|
it3("seeds a tombstone when no snapshot is provided", async () => {
|
|
872
1043
|
const s = `trunc-tomb-${uid()}`;
|
|
@@ -1019,6 +1190,229 @@ var runStoreTck = (options) => {
|
|
|
1019
1190
|
expect3(unblocked).toEqual([sibling]);
|
|
1020
1191
|
});
|
|
1021
1192
|
});
|
|
1193
|
+
describe3("query_stats", () => {
|
|
1194
|
+
it3("array input \u2014 returns head per stream, absent when not in input", async () => {
|
|
1195
|
+
const tag = uid();
|
|
1196
|
+
const sA = `qst-${tag}-a`;
|
|
1197
|
+
const sB = `qst-${tag}-b`;
|
|
1198
|
+
const sUnasked = `qst-${tag}-unasked`;
|
|
1199
|
+
await store.commit(
|
|
1200
|
+
sA,
|
|
1201
|
+
[inc(1), inc(2)],
|
|
1202
|
+
makeMeta({ stream: sA })
|
|
1203
|
+
);
|
|
1204
|
+
await store.commit(
|
|
1205
|
+
sB,
|
|
1206
|
+
[dec(5)],
|
|
1207
|
+
makeMeta({ stream: sB })
|
|
1208
|
+
);
|
|
1209
|
+
await store.commit(
|
|
1210
|
+
sUnasked,
|
|
1211
|
+
[inc(99)],
|
|
1212
|
+
makeMeta({ stream: sUnasked })
|
|
1213
|
+
);
|
|
1214
|
+
const stats = await store.query_stats([sA, sB]);
|
|
1215
|
+
expect3(stats.size).toBe(2);
|
|
1216
|
+
expect3(stats.get(sA)?.head.name).toBe("Incremented");
|
|
1217
|
+
expect3((stats.get(sA)?.head.data).amount).toBe(2);
|
|
1218
|
+
expect3(stats.get(sB)?.head.name).toBe("Decremented");
|
|
1219
|
+
expect3((stats.get(sB)?.head.data).amount).toBe(5);
|
|
1220
|
+
expect3(stats.has(sUnasked)).toBe(false);
|
|
1221
|
+
const empty = await store.query_stats([]);
|
|
1222
|
+
expect3(empty.size).toBe(0);
|
|
1223
|
+
const unknown = await store.query_stats([`qst-${tag}-missing`]);
|
|
1224
|
+
expect3(unknown.size).toBe(0);
|
|
1225
|
+
});
|
|
1226
|
+
it3("tail returns the earliest event per stream", async () => {
|
|
1227
|
+
const tag = uid();
|
|
1228
|
+
const s = `qst-tail-${tag}`;
|
|
1229
|
+
await store.commit(s, [inc(1)], makeMeta({ stream: s }));
|
|
1230
|
+
await store.commit(s, [inc(2)], makeMeta({ stream: s }));
|
|
1231
|
+
await store.commit(s, [inc(3)], makeMeta({ stream: s }));
|
|
1232
|
+
const stats = await store.query_stats([s], {
|
|
1233
|
+
tail: true
|
|
1234
|
+
});
|
|
1235
|
+
const r = stats.get(s);
|
|
1236
|
+
expect3(r?.head.name).toBe("Incremented");
|
|
1237
|
+
expect3((r?.head.data).amount).toBe(3);
|
|
1238
|
+
expect3(r?.tail?.name).toBe("Incremented");
|
|
1239
|
+
expect3((r?.tail?.data).amount).toBe(1);
|
|
1240
|
+
});
|
|
1241
|
+
it3("count + names \u2014 full aggregates including framework markers", async () => {
|
|
1242
|
+
const tag = uid();
|
|
1243
|
+
const s = `qst-cn-${tag}`;
|
|
1244
|
+
await store.commit(s, [inc(1)], makeMeta({ stream: s }));
|
|
1245
|
+
await store.truncate([{ stream: s, snapshot: { count: 99 } }]);
|
|
1246
|
+
await store.commit(
|
|
1247
|
+
s,
|
|
1248
|
+
[inc(2), inc(3), dec(1)],
|
|
1249
|
+
makeMeta({ stream: s })
|
|
1250
|
+
);
|
|
1251
|
+
const stats = await store.query_stats([s], {
|
|
1252
|
+
count: true,
|
|
1253
|
+
names: true
|
|
1254
|
+
});
|
|
1255
|
+
const r = stats.get(s);
|
|
1256
|
+
expect3(r?.count).toBe(4);
|
|
1257
|
+
expect3(r?.names?.[SNAP_EVENT]).toBe(1);
|
|
1258
|
+
expect3(r?.names?.Incremented).toBe(2);
|
|
1259
|
+
expect3(r?.names?.Decremented).toBe(1);
|
|
1260
|
+
expect3(r?.names?.[SNAP_EVENT]).toBe(1);
|
|
1261
|
+
});
|
|
1262
|
+
it3("exclude shifts head past filtered events; stream absent when all filtered", async () => {
|
|
1263
|
+
const tag = uid();
|
|
1264
|
+
const s = `qst-excl-${tag}`;
|
|
1265
|
+
const sAllOut = `qst-allout-${tag}`;
|
|
1266
|
+
await store.commit(
|
|
1267
|
+
s,
|
|
1268
|
+
[inc(1), dec(2), inc(3)],
|
|
1269
|
+
makeMeta({ stream: s })
|
|
1270
|
+
);
|
|
1271
|
+
await store.commit(
|
|
1272
|
+
sAllOut,
|
|
1273
|
+
[inc(7)],
|
|
1274
|
+
makeMeta({ stream: sAllOut })
|
|
1275
|
+
);
|
|
1276
|
+
const all = await store.query_stats([s]);
|
|
1277
|
+
expect3(all.get(s)?.head.name).toBe("Incremented");
|
|
1278
|
+
expect3((all.get(s)?.head.data).amount).toBe(3);
|
|
1279
|
+
const excl = await store.query_stats([s], {
|
|
1280
|
+
exclude: ["Incremented"]
|
|
1281
|
+
});
|
|
1282
|
+
expect3(excl.get(s)?.head.name).toBe("Decremented");
|
|
1283
|
+
expect3((excl.get(s)?.head.data).amount).toBe(2);
|
|
1284
|
+
const wipe = await store.query_stats([sAllOut], {
|
|
1285
|
+
exclude: ["Incremented", "Decremented", "Reset"]
|
|
1286
|
+
});
|
|
1287
|
+
expect3(wipe.has(sAllOut)).toBe(false);
|
|
1288
|
+
const noTomb = await store.query_stats([s], {
|
|
1289
|
+
exclude: [TOMBSTONE_EVENT]
|
|
1290
|
+
});
|
|
1291
|
+
expect3(noTomb.get(s)?.head.name).toBe("Incremented");
|
|
1292
|
+
});
|
|
1293
|
+
it3("before \u2014 time travel narrows head/tail/count", async () => {
|
|
1294
|
+
const tag = uid();
|
|
1295
|
+
const s = `qst-tt-${tag}`;
|
|
1296
|
+
const c1 = await store.commit(
|
|
1297
|
+
s,
|
|
1298
|
+
[inc(1)],
|
|
1299
|
+
makeMeta({ stream: s })
|
|
1300
|
+
);
|
|
1301
|
+
const c2 = await store.commit(
|
|
1302
|
+
s,
|
|
1303
|
+
[inc(2)],
|
|
1304
|
+
makeMeta({ stream: s })
|
|
1305
|
+
);
|
|
1306
|
+
await store.commit(s, [inc(3)], makeMeta({ stream: s }));
|
|
1307
|
+
const before = c2[0].id;
|
|
1308
|
+
const stats = await store.query_stats([s], {
|
|
1309
|
+
tail: true,
|
|
1310
|
+
count: true,
|
|
1311
|
+
before
|
|
1312
|
+
});
|
|
1313
|
+
const r = stats.get(s);
|
|
1314
|
+
expect3(r?.count).toBe(1);
|
|
1315
|
+
expect3(r?.head.id).toBe(c1[0].id);
|
|
1316
|
+
expect3(r?.tail?.id).toBe(c1[0].id);
|
|
1317
|
+
const empty = await store.query_stats([s], {
|
|
1318
|
+
before: 0
|
|
1319
|
+
});
|
|
1320
|
+
expect3(empty.has(s)).toBe(false);
|
|
1321
|
+
});
|
|
1322
|
+
it3("filter form \u2014 stream regex, stream_exact, empty {} match", async () => {
|
|
1323
|
+
const tag = uid();
|
|
1324
|
+
const sA = `qsf-${tag}-orders-1`;
|
|
1325
|
+
const sB = `qsf-${tag}-orders-2`;
|
|
1326
|
+
const sOther = `qsf-${tag}-users-1`;
|
|
1327
|
+
await store.commit(
|
|
1328
|
+
sA,
|
|
1329
|
+
[inc(1)],
|
|
1330
|
+
makeMeta({ stream: sA })
|
|
1331
|
+
);
|
|
1332
|
+
await store.commit(
|
|
1333
|
+
sB,
|
|
1334
|
+
[inc(2)],
|
|
1335
|
+
makeMeta({ stream: sB })
|
|
1336
|
+
);
|
|
1337
|
+
await store.commit(
|
|
1338
|
+
sOther,
|
|
1339
|
+
[inc(3)],
|
|
1340
|
+
makeMeta({ stream: sOther })
|
|
1341
|
+
);
|
|
1342
|
+
const orders = await store.query_stats({
|
|
1343
|
+
stream: `^qsf-${tag}-orders-`
|
|
1344
|
+
});
|
|
1345
|
+
expect3([...orders.keys()].sort()).toEqual([sA, sB].sort());
|
|
1346
|
+
const exact = await store.query_stats({
|
|
1347
|
+
stream: sA,
|
|
1348
|
+
stream_exact: true
|
|
1349
|
+
});
|
|
1350
|
+
expect3([...exact.keys()]).toEqual([sA]);
|
|
1351
|
+
const all = await store.query_stats({
|
|
1352
|
+
stream: `^qsf-${tag}-`
|
|
1353
|
+
});
|
|
1354
|
+
expect3([...all.keys()].sort()).toEqual([sA, sB, sOther].sort());
|
|
1355
|
+
});
|
|
1356
|
+
it3("compose with query_streams for subscription-level filters", async () => {
|
|
1357
|
+
const tag = uid();
|
|
1358
|
+
const a = `qsc-${tag}-a`;
|
|
1359
|
+
const b = `qsc-${tag}-b`;
|
|
1360
|
+
await store.subscribe([{ stream: a }, { stream: b }]);
|
|
1361
|
+
await store.commit(a, [inc(1)], makeMeta({ stream: a }));
|
|
1362
|
+
await store.commit(b, [inc(2)], makeMeta({ stream: b }));
|
|
1363
|
+
const leased = await store.claim(100, 0, `w-${uid()}`, 1e5);
|
|
1364
|
+
const mine = leased.find((l) => l.stream === a);
|
|
1365
|
+
expect3(mine).toBeDefined();
|
|
1366
|
+
const others = leased.filter((l) => l.stream !== a);
|
|
1367
|
+
await store.ack(others);
|
|
1368
|
+
await store.block([{ ...mine, error: "boom" }]);
|
|
1369
|
+
const blockedNames = [];
|
|
1370
|
+
await store.query_streams((p) => blockedNames.push(p.stream), {
|
|
1371
|
+
stream: `^qsc-${tag}-`,
|
|
1372
|
+
blocked: true
|
|
1373
|
+
});
|
|
1374
|
+
expect3(blockedNames).toEqual([a]);
|
|
1375
|
+
const stats = await store.query_stats(blockedNames);
|
|
1376
|
+
expect3(stats.get(a)?.head.name).toBe("Incremented");
|
|
1377
|
+
expect3(stats.has(b)).toBe(false);
|
|
1378
|
+
});
|
|
1379
|
+
it3("empty filter {} \u2014 matches every event-bearing stream", async () => {
|
|
1380
|
+
const tag = uid();
|
|
1381
|
+
const a = `qse-${tag}-a`;
|
|
1382
|
+
const b = `qse-${tag}-b`;
|
|
1383
|
+
await store.commit(a, [inc(1)], makeMeta({ stream: a }));
|
|
1384
|
+
await store.commit(b, [dec(2)], makeMeta({ stream: b }));
|
|
1385
|
+
const all = await store.query_stats({});
|
|
1386
|
+
expect3(all.has(a)).toBe(true);
|
|
1387
|
+
expect3(all.has(b)).toBe(true);
|
|
1388
|
+
});
|
|
1389
|
+
it3("stat-flag combinations \u2014 count-only, names-only, tail-only", async () => {
|
|
1390
|
+
const tag = uid();
|
|
1391
|
+
const s = `qsfl-${tag}`;
|
|
1392
|
+
await store.commit(
|
|
1393
|
+
s,
|
|
1394
|
+
[inc(1), inc(2), dec(3)],
|
|
1395
|
+
makeMeta({ stream: s })
|
|
1396
|
+
);
|
|
1397
|
+
const c = await store.query_stats([s], {
|
|
1398
|
+
count: true
|
|
1399
|
+
});
|
|
1400
|
+
expect3(c.get(s)?.count).toBe(3);
|
|
1401
|
+
expect3(c.get(s)?.names).toBeUndefined();
|
|
1402
|
+
expect3(c.get(s)?.tail).toBeUndefined();
|
|
1403
|
+
const n = await store.query_stats([s], {
|
|
1404
|
+
names: true
|
|
1405
|
+
});
|
|
1406
|
+
expect3(n.get(s)?.names).toEqual({ Incremented: 2, Decremented: 1 });
|
|
1407
|
+
expect3(n.get(s)?.count).toBeUndefined();
|
|
1408
|
+
expect3(n.get(s)?.tail).toBeUndefined();
|
|
1409
|
+
const t = await store.query_stats([s], { tail: true });
|
|
1410
|
+
expect3(t.get(s)?.tail?.name).toBe("Incremented");
|
|
1411
|
+
expect3((t.get(s)?.tail?.data).amount).toBe(1);
|
|
1412
|
+
expect3(t.get(s)?.count).toBeUndefined();
|
|
1413
|
+
expect3(t.get(s)?.names).toBeUndefined();
|
|
1414
|
+
});
|
|
1415
|
+
});
|
|
1022
1416
|
describe3("query_streams anchor contract", () => {
|
|
1023
1417
|
it3("plain regex without anchors is a substring match", async () => {
|
|
1024
1418
|
const tag = uid();
|