mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-07 02:37:14 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user