]> git.giacomolli.uk - onechat/commitdiff
Wait for the send back line in the retry test
authorAnderson A. Giacomolli <agiacomolli@gmail.com>
Tue, 10 Nov 2026 04:49:06 +0000 (01:49 -0300)
committerAnderson A. Giacomolli <agiacomolli@gmail.com>
Tue, 10 Nov 2026 04:49:06 +0000 (01:49 -0300)
The bot writes the end of a send outage to the log after the send
returns, so the fake server can hold the message before the line exists.
The test now waits for the line instead of reading the log once, which
made it fail now and then, also inside nix build.

telegram_test.go

index 2166bdfd3106adf159f0c84a8ac9eb5d5e8e65ae..60e9e86b8147888ca0d76ce84410f9adb316455c 100644 (file)
@@ -268,7 +268,13 @@ func TestBotTriesAgainAfterFailures(t *testing.T) {
        require.Contains(t, logs.String(), "<4>receive failed retry=1ms: 502")
        require.Contains(t, logs.String(), "<6>receive back after=")
        require.Contains(t, logs.String(), "<4>send failed retry=1s: 429")
-       require.Contains(t, logs.String(), "<6>send back after=")
+
+       // The bot logs the end of the outage after the send returns, so the line
+       // can come after the fake server has the message.
+       require.Eventually(t, func() bool {
+               return strings.Contains(logs.String(), "<6>send back after=")
+       }, 10*time.Second, time.Millisecond)
+
        require.NotContains(t, logs.String(), telegramTestToken)
 }