@dudousxd/nestjs-durable-testing 0.4.0 → 0.4.1
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/index.js +78 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -262,6 +262,84 @@ function runStateStoreContract(name, makeStore) {
|
|
|
262
262
|
1
|
|
263
263
|
]);
|
|
264
264
|
});
|
|
265
|
+
t("getLatestCheckpointByName returns the highest-seq match (and undefined for none)", async () => {
|
|
266
|
+
await store.createRun(run());
|
|
267
|
+
await store.saveCheckpoint(checkpoint({
|
|
268
|
+
seq: 0,
|
|
269
|
+
name: "event:progress",
|
|
270
|
+
output: {
|
|
271
|
+
pct: 10
|
|
272
|
+
}
|
|
273
|
+
}));
|
|
274
|
+
await store.saveCheckpoint(checkpoint({
|
|
275
|
+
seq: 1,
|
|
276
|
+
name: "charge",
|
|
277
|
+
output: {
|
|
278
|
+
id: "c1"
|
|
279
|
+
}
|
|
280
|
+
}));
|
|
281
|
+
await store.saveCheckpoint(checkpoint({
|
|
282
|
+
seq: 2,
|
|
283
|
+
name: "event:progress",
|
|
284
|
+
output: {
|
|
285
|
+
pct: 50
|
|
286
|
+
}
|
|
287
|
+
}));
|
|
288
|
+
await store.saveCheckpoint(checkpoint({
|
|
289
|
+
seq: 3,
|
|
290
|
+
name: "event:progress",
|
|
291
|
+
output: {
|
|
292
|
+
pct: 90
|
|
293
|
+
}
|
|
294
|
+
}));
|
|
295
|
+
const getLatestCheckpointByName = store.getLatestCheckpointByName;
|
|
296
|
+
expect(getLatestCheckpointByName).toBeDefined();
|
|
297
|
+
if (!getLatestCheckpointByName) return;
|
|
298
|
+
const latest = await getLatestCheckpointByName.call(store, "r1", "event:progress");
|
|
299
|
+
expect(latest?.seq).toBe(3);
|
|
300
|
+
expect(latest?.output).toEqual({
|
|
301
|
+
pct: 90
|
|
302
|
+
});
|
|
303
|
+
expect(await getLatestCheckpointByName.call(store, "r1", "event:missing")).toBeUndefined();
|
|
304
|
+
});
|
|
305
|
+
t("listCheckpointsByNamePrefix returns prefix matches ordered by seq (empty => none)", async () => {
|
|
306
|
+
await store.createRun(run());
|
|
307
|
+
await store.saveCheckpoint(checkpoint({
|
|
308
|
+
seq: 0,
|
|
309
|
+
name: "reserve"
|
|
310
|
+
}));
|
|
311
|
+
await store.saveCheckpoint(checkpoint({
|
|
312
|
+
seq: 1,
|
|
313
|
+
name: "spawn:0",
|
|
314
|
+
output: "child-a"
|
|
315
|
+
}));
|
|
316
|
+
await store.saveCheckpoint(checkpoint({
|
|
317
|
+
seq: 2,
|
|
318
|
+
name: "signal:child:c2"
|
|
319
|
+
}));
|
|
320
|
+
await store.saveCheckpoint(checkpoint({
|
|
321
|
+
seq: 3,
|
|
322
|
+
name: "event:progress"
|
|
323
|
+
}));
|
|
324
|
+
await store.saveCheckpoint(checkpoint({
|
|
325
|
+
seq: 4,
|
|
326
|
+
name: "spawn:1",
|
|
327
|
+
output: "child-b"
|
|
328
|
+
}));
|
|
329
|
+
const listCheckpointsByNamePrefix = store.listCheckpointsByNamePrefix;
|
|
330
|
+
expect(listCheckpointsByNamePrefix).toBeDefined();
|
|
331
|
+
if (!listCheckpointsByNamePrefix) return;
|
|
332
|
+
const matches = await listCheckpointsByNamePrefix.call(store, "r1", [
|
|
333
|
+
"signal:child:",
|
|
334
|
+
"spawn:"
|
|
335
|
+
]);
|
|
336
|
+
expect(matches.map((c) => c.name)).toEqual([
|
|
337
|
+
"spawn:0",
|
|
338
|
+
"signal:child:c2",
|
|
339
|
+
"spawn:1"
|
|
340
|
+
]);
|
|
341
|
+
expect(await listCheckpointsByNamePrefix.call(store, "r1", [])).toEqual([]);
|
|
342
|
+
});
|
|
265
343
|
t("round-trips checkpoint events and reads back a missing checkpoint as null", async () => {
|
|
266
344
|
await store.createRun(run());
|
|
267
345
|
await store.saveCheckpoint(checkpoint({
|