mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-09-07 06:17:52 +00:00
The alias module registers an inline-query handler, but pollingAllowedUpdates listed only message and callback_query. Telegram filters getUpdates on its side, so inline queries were dropped before reaching the bot — the handler never ran, and the omission left no log line or error to debug from. Adds a test tying the list to the kinds actually handled, since nothing else would catch the next such gap.
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
package telegram
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
)
|
|
|
|
// pollingAllowedUpdates is a silent gate: Telegram filters getUpdates on its
|
|
// side, so a handler for a kind missing from this list is never called and
|
|
// leaves no log line, no error, and nothing to debug from. Inline queries were
|
|
// dropped exactly this way once — the handler was registered and the list was
|
|
// not updated.
|
|
//
|
|
// This test is the tripwire. A module that starts handling a new update kind
|
|
// belongs in both places, and removing a kind here must be deliberate enough to
|
|
// require editing this list too.
|
|
func TestPollingAllowedUpdates_CoversEveryHandledKind(t *testing.T) {
|
|
// message — every /command, and the alias fallback
|
|
// callback_query — inline-keyboard buttons (stock dividends, loldle)
|
|
// inline_query — "@botname <prefix>" alias lookups
|
|
want := []string{"message", "callback_query", "inline_query"}
|
|
|
|
for _, kind := range want {
|
|
if !slices.Contains(pollingAllowedUpdates, kind) {
|
|
t.Errorf("%q missing from pollingAllowedUpdates; its handlers will never fire", kind)
|
|
}
|
|
}
|
|
if len(pollingAllowedUpdates) != len(want) {
|
|
t.Errorf("pollingAllowedUpdates = %v, want exactly %v — an unhandled kind costs bandwidth for nothing",
|
|
pollingAllowedUpdates, want)
|
|
}
|
|
}
|