(t *testing.T)
| 74 | } |
| 75 | |
| 76 | func TestLoggingHandler_PassesRequestToHandler(t *testing.T) { |
| 77 | var handlerCalled bool |
| 78 | inner := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 79 | handlerCalled = true |
| 80 | w.WriteHeader(http.StatusOK) |
| 81 | }) |
| 82 | |
| 83 | handler := loggingHandler(inner) |
| 84 | |
| 85 | req := httptest.NewRequest(http.MethodGet, "/test-path", nil) |
| 86 | rec := httptest.NewRecorder() |
| 87 | handler.ServeHTTP(rec, req) |
| 88 | |
| 89 | if !handlerCalled { |
| 90 | t.Error("loggingHandler did not call the inner handler") |
| 91 | } |
| 92 | if rec.Code != http.StatusOK { |
| 93 | t.Errorf("response code = %d, want %d", rec.Code, http.StatusOK) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | func TestLoggingHandler_SanitizesPath(t *testing.T) { |
| 98 | // The handler should not panic on paths with newlines/carriage returns |
nothing calls this directly
no test coverage detected