MCPcopy Create free account
hub / github.com/pace/bricks / TestLoggingHandler

Function TestLoggingHandler

maintenance/log/handler_test.go:12–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestLoggingHandler(t *testing.T) {
13 rec := httptest.NewRecorder()
14 req := httptest.NewRequest("GET", "/test", nil)
15
16 mux := http.NewServeMux()
17 mux.HandleFunc("/test", func(w http.ResponseWriter, r *http.Request) {
18 if RequestID(r) == "" {
19 t.Error("Request should have request id")
20 }
21 w.WriteHeader(201)
22 })
23 Handler()(mux).ServeHTTP(rec, req)
24
25 resp := rec.Result()
26 defer resp.Body.Close()
27
28 if resp.StatusCode != 201 {
29 t.Error("expected 201 status code")
30 }
31}
32
33func Test_isPrivate(t *testing.T) {
34 tests := []struct {

Callers

nothing calls this directly

Calls 6

RequestIDFunction · 0.85
CloseMethod · 0.80
HandlerFunction · 0.70
ErrorMethod · 0.45
WriteHeaderMethod · 0.45
ServeHTTPMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…