@dudousxd/nestjs-durable-testing 0.5.0 → 0.6.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/dist/index.js CHANGED
@@ -317,6 +317,81 @@ function runStateStoreContract(name, makeStore) {
317
317
  expect(dead?.status).toBe("dead");
318
318
  expect(dead?.recoveryAttempts).toBe(4);
319
319
  });
320
+ t("deleteRun removes the run and all its rows (checkpoints, waiters, attributes)", async () => {
321
+ await store.createRun(run({
322
+ searchAttributes: {
323
+ tier: "pro"
324
+ }
325
+ }));
326
+ await store.saveCheckpoint(checkpoint());
327
+ await store.putSignalWaiter({
328
+ token: "approve-r1",
329
+ runId: "r1",
330
+ seq: 0
331
+ });
332
+ await store.deleteRun("r1");
333
+ expect(await store.getRun("r1")).toBeNull();
334
+ expect(await store.listCheckpoints("r1")).toEqual([]);
335
+ expect(await store.listSignalWaiters("approve-")).toEqual([]);
336
+ expect(await store.listRuns({
337
+ attributes: [
338
+ {
339
+ key: "tier",
340
+ op: "eq",
341
+ value: "pro"
342
+ }
343
+ ]
344
+ })).toEqual([]);
345
+ });
346
+ t("deleteRun is a no-op for a missing run", async () => {
347
+ await expect(store.deleteRun("nope")).resolves.toBeUndefined();
348
+ });
349
+ t("updateRun maps every patchable field \u2014 clears error and patches tags/lockedBy/input/timers", async () => {
350
+ await store.createRun(run({
351
+ status: "failed",
352
+ error: {
353
+ message: "boom"
354
+ },
355
+ tags: [
356
+ "old"
357
+ ],
358
+ lockedBy: "owner-1"
359
+ }));
360
+ await store.updateRun("r1", {
361
+ status: "completed",
362
+ output: {
363
+ ok: true
364
+ },
365
+ error: void 0,
366
+ input: {
367
+ orderId: "o2"
368
+ },
369
+ tags: [
370
+ "x",
371
+ "y"
372
+ ],
373
+ lockedBy: "owner-2",
374
+ wakeAt: 123456,
375
+ lockedUntil: 222222,
376
+ updatedAt: at
377
+ });
378
+ const r = await store.getRun("r1");
379
+ expect(r?.status).toBe("completed");
380
+ expect(r?.output).toEqual({
381
+ ok: true
382
+ });
383
+ expect(r?.error).toBeUndefined();
384
+ expect(r?.input).toEqual({
385
+ orderId: "o2"
386
+ });
387
+ expect(r?.tags).toEqual([
388
+ "x",
389
+ "y"
390
+ ]);
391
+ expect(r?.lockedBy).toBe("owner-2");
392
+ expect(r?.wakeAt).toBe(123456);
393
+ expect(r?.lockedUntil).toBe(222222);
394
+ });
320
395
  t("upserts checkpoints, reads them by (runId, seq), and lists them ordered by seq", async () => {
321
396
  await store.createRun(run());
322
397
  await store.saveCheckpoint(checkpoint());