Files
tiennm99 59c74de9a9 refactor(lol): move the subscriber list and daily push fan-out into a shared package
The subscriber store, the once-per-day claim, the terminal-error
classifier and the throttled fan-out with dead-chat pruning now live in
internal/modules/util/subscription so another module can offer an
opt-in daily push. Stored document shapes and keys are unchanged.
2026-10-02 13:06:07 +07:00

44 lines
1.2 KiB
Go

package subscription
import (
"errors"
"testing"
)
func TestClassifyTerminal(t *testing.T) {
chatWide := []string{
"Forbidden: bot was blocked by the user",
"Forbidden: user is deactivated",
"Bad Request: chat not found",
"Bad Request: group chat was upgraded to a supergroup chat",
}
for _, msg := range chatWide {
if got := ClassifyTerminal(errors.New(msg)); got != TerminalChatWide {
t.Errorf("ClassifyTerminal(%q) = %v, want TerminalChatWide", msg, got)
}
}
topicOnly := []string{
"Bad Request: have no rights to send a message",
}
for _, msg := range topicOnly {
if got := ClassifyTerminal(errors.New(msg)); got != TerminalTopicOnly {
t.Errorf("ClassifyTerminal(%q) = %v, want TerminalTopicOnly", msg, got)
}
}
transients := []string{
"connection reset by peer",
"Too Many Requests: retry after 30",
"context deadline exceeded",
}
for _, msg := range transients {
if got := ClassifyTerminal(errors.New(msg)); got != TerminalNone {
t.Errorf("ClassifyTerminal(%q) = %v, want TerminalNone (transient)", msg, got)
}
}
if got := ClassifyTerminal(nil); got != TerminalNone {
t.Errorf("ClassifyTerminal(nil) = %v, want TerminalNone", got)
}
}