X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/087d725b5ab41ad34ffd24938482d45a8b99a080..d28e3b2858db322899a81b59a30400c1acad2b42:/telegram_api_test.go?ds=inline diff --git a/telegram_api_test.go b/telegram_api_test.go index 43e952e..98aa232 100644 --- a/telegram_api_test.go +++ b/telegram_api_test.go @@ -123,6 +123,7 @@ func TestSendCallsTimeOutOnAStalledConnection(t *testing.T) { api.sendTimeout = time.Hour ctx, cancel := context.WithCancel(t.Context()) time.AfterFunc(50*time.Millisecond, cancel) + start = time.Now() err = tc.send(ctx, api) require.Error(t, err) @@ -155,6 +156,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) { name: "rate limit waits as asked", reply: func(w http.ResponseWriter) { w.WriteHeader(http.StatusTooManyRequests) + _, _ = io.WriteString(w, `{"ok":false,"error_code":429,"description":"Too Many Requests: retry after 3","parameters":{"retry_after":3}}`) }, retry: true, @@ -165,6 +167,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) { name: "server error page is retried", reply: func(w http.ResponseWriter) { w.WriteHeader(http.StatusBadGateway) + _, _ = io.WriteString(w, "bad gateway") }, retry: true, @@ -174,6 +177,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) { name: "token echoed in a description is hidden", reply: func(w http.ResponseWriter) { w.WriteHeader(http.StatusUnauthorized) + _, _ = io.WriteString(w, `{"ok":false,"error_code":401,"description":"Unauthorized: bot`+telegramTestToken+`"}`) }, retry: false, @@ -183,6 +187,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) { name: "bad request is a refusal", reply: func(w http.ResponseWriter) { w.WriteHeader(http.StatusBadRequest) + _, _ = io.WriteString(w, `{"ok":false,"error_code":400,"description":"Bad Request: can't parse"}`) }, retry: false, @@ -193,6 +198,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) { name: "unknown method is a refusal", reply: func(w http.ResponseWriter) { w.WriteHeader(http.StatusNotFound) + _, _ = io.WriteString(w, `{"ok":false,"error_code":404,"description":"Not Found"}`) }, retry: false, @@ -203,6 +209,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) { name: "not found page of a proxy is not a refusal", reply: func(w http.ResponseWriter) { w.WriteHeader(http.StatusNotFound) + _, _ = io.WriteString(w, "not found") }, retry: false,