MCPcopy Index your code
hub / github.com/felixge/httpsnoop / TestWrap_preservesWriteHookForWriteString

Function TestWrap_preservesWriteHookForWriteString

wrap_test.go:29–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27func (w *flushErrorResponseWriter) FlushError() error { return w.err }
28
29func TestWrap_preservesWriteHookForWriteString(t *testing.T) {
30 var got string
31 w := Wrap(httptest.NewRecorder(), Hooks{
32 Write: func(next WriteFunc) WriteFunc {
33 return func(p []byte) (int, error) {
34 got = string(p)
35 return next(p)
36 }
37 },
38 })
39
40 if _, ok := w.(io.StringWriter); !ok {
41 t.Fatal("wrapped writer should expose io.StringWriter")
42 }
43 if _, err := io.WriteString(w, "hello"); err != nil {
44 t.Fatal(err)
45 }
46 if got != "hello" {
47 t.Fatalf("Write hook saw %q, want %q", got, "hello")
48 }
49}
50
51func TestWrap_preservesFlushHookForFlushError(t *testing.T) {
52 flushed := false

Callers

nothing calls this directly

Calls 2

WrapFunction · 0.85
WriteStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…