From 33058c8eed533f5315586bead06ff8137bf1273a Mon Sep 17 00:00:00 2001 From: Sanaei Date: Sun, 6 Sep 2026 17:32:01 +0200 Subject: [PATCH] fix(tgbot): use a token telego accepts in the edit-message tests telego.NewBot validates the token against `^\d+:[\w-]{35}$` before any option is applied, so the "test-token" literal in the two not-modified tests failed with "telego: invalid token format" and the go-test and race jobs went red on every run since #6340. Use a placeholder token that matches the format; the tests now reach the mock API server, pass with the guard in place and fail without it. --- internal/web/service/tgbot/tgbot_send_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/web/service/tgbot/tgbot_send_test.go b/internal/web/service/tgbot/tgbot_send_test.go index a47211b71..ce338fa03 100644 --- a/internal/web/service/tgbot/tgbot_send_test.go +++ b/internal/web/service/tgbot/tgbot_send_test.go @@ -37,6 +37,9 @@ func TestIsTelegramNotModifiedError(t *testing.T) { } } +// telego.NewBot rejects any token that does not match `^\d+:[\w-]{35}$`. +var testBotToken = "123456:" + strings.Repeat("a", 35) + func TestEditMessageTgBotSkipsNotModified(t *testing.T) { // Mock Telegram API that always returns "message is not modified". mock := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -53,7 +56,7 @@ func TestEditMessageTgBotSkipsNotModified(t *testing.T) { origBot := bot t.Cleanup(func() { bot = origBot }) var err error - bot, err = telego.NewBot("test-token", telego.WithAPIServer(mock.URL)) + bot, err = telego.NewBot(testBotToken, telego.WithAPIServer(mock.URL)) if err != nil { t.Fatalf("NewBot: %v", err) } @@ -85,7 +88,7 @@ func TestEditMessageCallbackTgBotSkipsNotModified(t *testing.T) { origBot := bot t.Cleanup(func() { bot = origBot }) var err error - bot, err = telego.NewBot("test-token", telego.WithAPIServer(mock.URL)) + bot, err = telego.NewBot(testBotToken, telego.WithAPIServer(mock.URL)) if err != nil { t.Fatalf("NewBot: %v", err) }