test: merge telegram probe success retry variants
This commit is contained in:
@@ -47,30 +47,30 @@ describe("probeTelegram retry logic", () => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("should succeed if the first attempt succeeds", async () => {
|
||||
mockGetMeSuccess();
|
||||
mockGetWebhookInfoSuccess();
|
||||
await expectSuccessfulProbe(2);
|
||||
});
|
||||
|
||||
it("should retry and succeed if first attempt fails but second succeeds", async () => {
|
||||
// 1st attempt: Network error
|
||||
fetchMock.mockRejectedValueOnce(new Error("Network timeout"));
|
||||
it.each([
|
||||
{
|
||||
errors: [],
|
||||
expectedCalls: 2,
|
||||
retryCount: 0,
|
||||
},
|
||||
{
|
||||
errors: ["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();
|
||||
mockGetWebhookInfoSuccess();
|
||||
await expectSuccessfulProbe(3, 1);
|
||||
});
|
||||
|
||||
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);
|
||||
await expectSuccessfulProbe(expectedCalls, retryCount);
|
||||
});
|
||||
|
||||
it("should fail after 3 unsuccessful attempts", async () => {
|
||||
|
||||
Reference in New Issue
Block a user