X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/4b063ca25798c78cc03d1d07f67b02c94c95248d..a345df4e4bbf9dbaf3da1ce548896eef8f515de3:/telegram_test.go?ds=sidebyside diff --git a/telegram_test.go b/telegram_test.go index d18e794..b1cd6ae 100644 --- a/telegram_test.go +++ b/telegram_test.go @@ -202,6 +202,29 @@ func TestBotTriesAgainAfterFailures(t *testing.T) { require.NotContains(t, logs.String(), testBotToken) } +func TestDeliverTriesAgainAfterATimeout(t *testing.T) { + telegram := newFakeBot(t) + stalls := 1 + telegram.stall = func(call fakeBotCall) bool { + if call.method != "sendMessage" || stalls == 0 { + return false + } + + stalls-- + + return true + } + + bot, logs := startTestBot(t, telegram) + bot.api.sendTimeout = 50 * time.Millisecond + bot.deliver(t.Context(), "hello") + + require.Equal(t, []string{"hello"}, telegram.Sent()) + require.Len(t, telegram.Calls(), 2) + require.Contains(t, logs.String(), "no valid answer") + require.NotContains(t, logs.String(), testBotToken) +} + func TestBotLogsNoTokenWhenTheNetworkFails(t *testing.T) { telegram := newFakeBot(t) telegram.Close()