From 3e6aed436277fbb686ba8a2e8e3e82ce8d4c7103 Mon Sep 17 00:00:00 2001 From: Dmitry Verkhoturov Date: Wed, 28 Jun 2023 22:18:06 +0200 Subject: [PATCH] fix TestTelegramConfirmedRequest failing in GitHub Actions The reason is likely slow work of goroutines due to limited CPU. --- provider/telegram_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/provider/telegram_test.go b/provider/telegram_test.go index 8aaa9f87..5121c7cd 100644 --- a/provider/telegram_test.go +++ b/provider/telegram_test.go @@ -142,14 +142,13 @@ func TestTelegramConfirmedRequest(t *testing.T) { servedToken = resp.Token mu.Unlock() - time.Sleep(apiPollInterval * 2) - - // The token should be confirmed by now - r = httptest.NewRequest("GET", fmt.Sprintf("/?token=%s", resp.Token), nil) - w = httptest.NewRecorder() - tg.LoginHandler(w, r) - - assert.Equal(t, http.StatusOK, w.Code, "response code should be 200") + // Check the token confirmation + assert.Eventually(t, func() bool { + r = httptest.NewRequest("GET", fmt.Sprintf("/?token=%s", resp.Token), nil) + w = httptest.NewRecorder() + tg.LoginHandler(w, r) + return w.Code == http.StatusOK + }, apiPollInterval*10, apiPollInterval, "response code should be 200") info := struct { Name string `name:"name"`