(t *testing.T)
| 2769 | } |
| 2770 | |
| 2771 | func TestMethodNotAllowed(t *testing.T) { |
| 2772 | handler := func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) } |
| 2773 | router := NewRouter() |
| 2774 | router.HandleFunc("/thing", handler).Methods(http.MethodGet) |
| 2775 | router.HandleFunc("/something", handler).Methods(http.MethodGet) |
| 2776 | |
| 2777 | w := NewRecorder() |
| 2778 | req := newRequest(http.MethodPut, "/thing") |
| 2779 | |
| 2780 | router.ServeHTTP(w, req) |
| 2781 | |
| 2782 | if w.Code != http.StatusMethodNotAllowed { |
| 2783 | t.Fatalf("Expected status code 405 (got %d)", w.Code) |
| 2784 | } |
| 2785 | } |
| 2786 | |
| 2787 | type customMethodNotAllowedHandler struct { |
| 2788 | msg string |
nothing calls this directly
no test coverage detected