mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 17:04:32 +00:00
test: merge telegram probe success retry variants
This commit is contained in:
@@ -47,30 +47,30 @@ describe("probeTelegram retry logic", () => {
|
|||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should succeed if the first attempt succeeds", async () => {
|
it.each([
|
||||||
mockGetMeSuccess();
|
{
|
||||||
mockGetWebhookInfoSuccess();
|
errors: [],
|
||||||
await expectSuccessfulProbe(2);
|
expectedCalls: 2,
|
||||||
});
|
retryCount: 0,
|
||||||
|
},
|
||||||
it("should retry and succeed if first attempt fails but second succeeds", async () => {
|
{
|
||||||
// 1st attempt: Network error
|
errors: ["Network timeout"],
|
||||||
fetchMock.mockRejectedValueOnce(new Error("Network timeout"));
|
expectedCalls: 3,
|
||||||
|
retryCount: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
errors: ["Network error 1", "Network error 2"],
|
||||||
|
expectedCalls: 4,
|
||||||
|
retryCount: 2,
|
||||||
|
},
|
||||||
|
])("succeeds after retry pattern %#", async ({ errors, expectedCalls, retryCount }) => {
|
||||||
|
for (const message of errors) {
|
||||||
|
fetchMock.mockRejectedValueOnce(new Error(message));
|
||||||
|
}
|
||||||
|
|
||||||
mockGetMeSuccess();
|
mockGetMeSuccess();
|
||||||
mockGetWebhookInfoSuccess();
|
mockGetWebhookInfoSuccess();
|
||||||
await expectSuccessfulProbe(3, 1);
|
await expectSuccessfulProbe(expectedCalls, retryCount);
|
||||||
});
|
|
||||||
|
|
||||||
it("should retry twice and succeed on the third attempt", async () => {
|
|
||||||
// 1st attempt: Network error
|
|
||||||
fetchMock.mockRejectedValueOnce(new Error("Network error 1"));
|
|
||||||
// 2nd attempt: Network error
|
|
||||||
fetchMock.mockRejectedValueOnce(new Error("Network error 2"));
|
|
||||||
|
|
||||||
mockGetMeSuccess();
|
|
||||||
mockGetWebhookInfoSuccess();
|
|
||||||
await expectSuccessfulProbe(4, 2);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should fail after 3 unsuccessful attempts", async () => {
|
it("should fail after 3 unsuccessful attempts", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user