(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestHTTPHandlerProcessesPush(t *testing.T) { |
| 16 | t.Parallel() |
| 17 | |
| 18 | handler := &HTTPHandler{ |
| 19 | Config: HTTPConfig{ |
| 20 | Path: "/hook", |
| 21 | Account: "a@example.com", |
| 22 | BodyLimit: 1024, |
| 23 | HasHook: true, |
| 24 | }, |
| 25 | Authorize: func(*http.Request) bool { |
| 26 | return true |
| 27 | }, |
| 28 | Process: func(_ context.Context, notification Notification) (*ProcessedPayload, error) { |
| 29 | if notification.HistoryID != "200" || notification.MessageID != "push-1" { |
| 30 | t.Fatalf("notification = %#v", notification) |
| 31 | } |
| 32 | |
| 33 | return &ProcessedPayload{Payload: &Payload{HistoryID: "200"}}, nil |
| 34 | }, |
| 35 | } |
| 36 | |
| 37 | response := httptest.NewRecorder() |
| 38 | handler.ServeHTTP(response, pushRequest(t, "a@example.com", "200", "push-1")) |
| 39 | |
| 40 | if response.Code != http.StatusOK { |
| 41 | t.Fatalf("status = %d", response.Code) |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | func TestHTTPHandlerMapsNoMessagesAndRateLimit(t *testing.T) { |
| 46 | t.Parallel() |
nothing calls this directly
no test coverage detected