MCPcopy Create free account
hub / github.com/github/gh-aw / TestLoggingHandler_PassesRequestToHandler

Function TestLoggingHandler_PassesRequestToHandler

pkg/cli/mcp_server_http_test.go:76–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

74}
75
76func 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
97func TestLoggingHandler_SanitizesPath(t *testing.T) {
98 // The handler should not panic on paths with newlines/carriage returns

Callers

nothing calls this directly

Calls 3

loggingHandlerFunction · 0.85
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected