]> git.giacomolli.uk - onechat/blobdiff - telegram_test.go
Check Go names and declarations with revive
[onechat] / telegram_test.go
index 48e550392fee45ad3f8ceef0e7e02cb6deeb0372..e360045f50341bd027b29ff631ec456ae6e1638c 100644 (file)
@@ -16,7 +16,7 @@ import (
 
 func TestOwnerTalksToTheAgentThroughTelegram(t *testing.T) {
        server := newModelFake(t)
 
 func TestOwnerTalksToTheAgentThroughTelegram(t *testing.T) {
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("Hello from the agent.")}, 100, 0, 5))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("Hello from the agent.")}, 100, 0, 5))
        }
 
@@ -100,7 +100,7 @@ func TestStopFromTelegramInterruptsTheTurn(t *testing.T) {
                close(release)
        })
 
                close(release)
        })
 
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(_ http.ResponseWriter, _ ModelFakeCall) {
                close(arrived)
                <-release
        }
                close(arrived)
                <-release
        }
@@ -200,7 +200,7 @@ func TestBotSkipsTheWorkOfWhatsAppAndTheSchedules(t *testing.T) {
 
 func TestBotStartsAtTheStoredOffset(t *testing.T) {
        server := newModelFake(t)
 
 func TestBotStartsAtTheStoredOffset(t *testing.T) {
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("ok")}, 100, 0, 5))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("ok")}, 100, 0, 5))
        }
 
@@ -223,7 +223,7 @@ func TestBotStartsAtTheStoredOffset(t *testing.T) {
        terminal.WaitFor(t, "[connected to OneChat]")
        telegramWaitForSent(t, telegram, "ok")
 
        terminal.WaitFor(t, "[connected to OneChat]")
        telegramWaitForSent(t, telegram, "ok")
 
-       require.Equal(t, float64(10), telegram.Calls()[0].params["offset"])
+       require.InDelta(t, float64(10), telegram.Calls()[0].params["offset"], 0)
        require.NotContains(t, terminal.Output(), "handled before the restart")
 
        require.Eventually(t, func() bool {
        require.NotContains(t, terminal.Output(), "handled before the restart")
 
        require.Eventually(t, func() bool {
@@ -234,7 +234,7 @@ func TestBotStartsAtTheStoredOffset(t *testing.T) {
 
 func TestBotTriesAgainAfterFailures(t *testing.T) {
        server := newModelFake(t)
 
 func TestBotTriesAgainAfterFailures(t *testing.T) {
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("ok")}, 100, 0, 5))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("ok")}, 100, 0, 5))
        }
 
@@ -301,7 +301,7 @@ func TestDeliverTriesAgainAfterATimeout(t *testing.T) {
 func TestRepliesGoAsRichMessages(t *testing.T) {
        reply := "**Done.** The table:\n\n| Name | Size |\n|:-----|-----:|\n| `a.go` | 10 |\n\n- one\n- two\n\n```go\nx := 1\n```"
        server := newModelFake(t)
 func TestRepliesGoAsRichMessages(t *testing.T) {
        reply := "**Done.** The table:\n\n| Name | Size |\n|:-----|-----:|\n| `a.go` | 10 |\n\n- one\n- two\n\n```go\nx := 1\n```"
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem(reply)}, 100, 0, 5))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem(reply)}, 100, 0, 5))
        }
 
@@ -569,7 +569,7 @@ func TestRefusedRichPartGoesWithTheTextAsWritten(t *testing.T) {
                require.LessOrEqual(t, telegramUTF16Units(text), telegramMessageUnits)
        }
 
                require.LessOrEqual(t, telegramUTF16Units(text), telegramMessageUnits)
        }
 
-       require.True(t, reply == strings.Join(fallback, "")+telegramUnescapeTags(rich[0]), "reply is not sent once and whole")
+       require.Equal(t, reply, strings.Join(fallback, "")+telegramUnescapeTags(rich[0]), "reply is not sent once and whole")
 }
 
 func TestRefusedEntitiesGoAgainAsPlainText(t *testing.T) {
 }
 
 func TestRefusedEntitiesGoAgainAsPlainText(t *testing.T) {
@@ -615,7 +615,7 @@ func TestBotLogsNoTokenWhenTheNetworkFails(t *testing.T) {
 
 func TestBotLogsAnOutageOnlyAtItsStartAndEnd(t *testing.T) {
        server := newModelFake(t)
 
 func TestBotLogsAnOutageOnlyAtItsStartAndEnd(t *testing.T) {
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("ok")}, 100, 0, 5))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("ok")}, 100, 0, 5))
        }