(new): v1.2 release
Golang lint / lint (push) Successful in 11m32s

This commit is contained in:
2026-08-19 14:58:25 +03:00
parent f03a081ed6
commit 29b208eeec
79 changed files with 7301 additions and 2060 deletions
+30
View File
@@ -41,11 +41,30 @@ func TestAsyncMiddlewareRecoversPanic(t *testing.T) {
if event.Err == nil {
t.Fatal("panic error was not reported")
}
if !errors.Is(event.Err, ErrHandlerPanic) {
t.Fatalf("expected ErrHandlerPanic, got %v", event.Err)
}
case <-time.After(time.Second):
t.Fatal("timed out waiting for async middleware error")
}
}
func TestSyncMiddlewareRecoversPanic(t *testing.T) {
observer := &middlewareErrorObserver{errors: make(chan ErrorEvent, 1)}
ctx := &MessageContext{observer: observer}
middleware := NewMiddleware[NoData]("panic", func(ctx *MessageContext, db NoData) bool {
panic("boom")
})
if middleware.Execute(ctx, NoData{}) {
t.Fatal("panicking synchronous middleware continued execution")
}
event := <-observer.errors
if !errors.Is(event.Err, ErrHandlerPanic) {
t.Fatalf("expected ErrHandlerPanic, got %v", event.Err)
}
}
func TestMiddlewareRejectsNilExecutor(t *testing.T) {
observer := &middlewareErrorObserver{errors: make(chan ErrorEvent, 1)}
ctx := &MessageContext{observer: observer}
@@ -171,3 +190,14 @@ func TestPluginCommandGroupRegistersBuiltCommands(t *testing.T) {
plugin.CommandGroup("ignored", nil)
plugin.AddCommandGroup(nil)
}
func TestPluginSkipsNilHandlers(t *testing.T) {
plugin := NewPlugin[NoData]("nil")
plugin.AddCommand(NewCommand[NoData]("command", nil))
plugin.AddPayload(NewCommand[NoData]("payload", nil))
plugin.AddUpdateHandler(tgapi.UpdateTypeEditedMessage, nil)
if len(plugin.commands) != 0 || len(plugin.payloads) != 0 || len(plugin.handlers) != 0 {
t.Fatalf("nil handlers were registered: commands=%d payloads=%d updates=%d", len(plugin.commands), len(plugin.payloads), len(plugin.handlers))
}
}