MCPcopy
hub / github.com/rs/zerolog / TestMethodHandler

Function TestMethodHandler

hlog/hlog_test.go:60–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestMethodHandler(t *testing.T) {
61 out := &bytes.Buffer{}
62 r := &http.Request{
63 Method: "POST",
64 }
65 h := MethodHandler("method")(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
66 l := FromRequest(r)
67 l.Log().Msg("")
68 }))
69 h = NewHandler(zerolog.New(out))(h)
70 h.ServeHTTP(nil, r)
71 if want, got := `{"method":"POST"}`+"\n", decodeIfBinary(out); want != got {
72 t.Errorf("Invalid log output, got: %s, want: %s", got, want)
73 }
74}
75
76func TestRequestHandler(t *testing.T) {
77 out := &bytes.Buffer{}

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
MethodHandlerFunction · 0.85
FromRequestFunction · 0.85
NewHandlerFunction · 0.85
decodeIfBinaryFunction · 0.85
MsgMethod · 0.80
LogMethod · 0.65

Tested by

no test coverage detected