| ... | ... | @@ -62,24 +62,26 @@ describe("checkpointDiffQueryOptions", () => { |
| 62 | 62 | cacheScope: "turn:abc", |
| 63 | 63 | }); |
| 64 | 64 | const retry = options.retry; |
| 65 | expect(typeof retry).toBe("function"); |
| 66 | if (typeof retry !== "function") { |
| 67 | throw new Error("Expected retry to be a function."); |
| 68 | } |
| 65 | 69 | |
| 66 | | expect(retry?.(1, new Error("Checkpoint turn count 2 exceeds current turn count 1."))).toBe( |
| 67 | | true, |
| 68 | | ); |
| 70 | expect(retry(1, new Error("Checkpoint turn count 2 exceeds current turn count 1."))).toBe(true); |
| 69 | 71 | expect( |
| 70 | | retry?.( |
| 72 | retry( |
| 71 | 73 | 11, |
| 72 | 74 | new Error("Filesystem checkpoint is unavailable for turn 2 in thread thread-1."), |
| 73 | 75 | ), |
| 74 | 76 | ).toBe(true); |
| 75 | 77 | expect( |
| 76 | | retry?.( |
| 78 | retry( |
| 77 | 79 | 12, |
| 78 | 80 | new Error("Filesystem checkpoint is unavailable for turn 2 in thread thread-1."), |
| 79 | 81 | ), |
| 80 | 82 | ).toBe(false); |
| 81 | | expect(retry?.(2, new Error("Something else failed."))).toBe(true); |
| 82 | | expect(retry?.(3, new Error("Something else failed."))).toBe(false); |
| 83 | expect(retry(2, new Error("Something else failed."))).toBe(true); |
| 84 | expect(retry(3, new Error("Something else failed."))).toBe(false); |
| 83 | 85 | }); |
| 84 | 86 | |
| 85 | 87 | it("backs off longer for checkpoint-not-ready errors", () => { |
| ... | ... | @@ -91,12 +93,16 @@ describe("checkpointDiffQueryOptions", () => { |
| 91 | 93 | cacheScope: "turn:abc", |
| 92 | 94 | }); |
| 93 | 95 | const retryDelay = options.retryDelay; |
| 96 | expect(typeof retryDelay).toBe("function"); |
| 97 | if (typeof retryDelay !== "function") { |
| 98 | throw new Error("Expected retryDelay to be a function."); |
| 99 | } |
| 94 | 100 | |
| 95 | | const checkpointDelay = retryDelay?.( |
| 101 | const checkpointDelay = retryDelay( |
| 96 | 102 | 4, |
| 97 | 103 | new Error("Checkpoint turn count 2 exceeds current turn count 1."), |
| 98 | 104 | ); |
| 99 | | const genericDelay = retryDelay?.(4, new Error("Network failure")); |
| 105 | const genericDelay = retryDelay(4, new Error("Network failure")); |
| 100 | 106 | |
| 101 | 107 | expect(typeof checkpointDelay).toBe("number"); |
| 102 | 108 | expect(typeof genericDelay).toBe("number"); |