(t *testing.T)
| 82 | } |
| 83 | |
| 84 | func TestWebhookHandler_ReadBodyError(t *testing.T) { |
| 85 | debugHandler := &mockDebugHandler{} |
| 86 | errorsHandler := &mockErrorsHandler{} |
| 87 | |
| 88 | bot := &Bot{ |
| 89 | debugHandler: func(format string, args ...any) { |
| 90 | debugHandler.Handle(format, args...) |
| 91 | }, |
| 92 | errorsHandler: func(err error) { |
| 93 | errorsHandler.Handle(err) |
| 94 | }, |
| 95 | } |
| 96 | |
| 97 | req := httptest.NewRequest(http.MethodPost, "/", errReader(errors.New("read error"))) |
| 98 | w := httptest.NewRecorder() |
| 99 | |
| 100 | handler := bot.WebhookHandler() |
| 101 | handler(w, req) |
| 102 | |
| 103 | if len(errorsHandler.errors) == 0 { |
| 104 | t.Fatal("Expected an error, but none occurred") |
| 105 | } |
| 106 | |
| 107 | if capturedError := errorsHandler.errors[0]; capturedError == nil || !containsString(capturedError.Error(), "read error") { |
| 108 | t.Fatalf("Expected read body error, got %v", capturedError) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | func TestWebhookHandler_DecodeError(t *testing.T) { |
| 113 | debugHandler := &mockDebugHandler{} |
nothing calls this directly
no test coverage detected