MCPcopy Create free account
hub / github.com/imroc/req / TestDumpRequestBodyWriteCloser

Function TestDumpRequestBodyWriteCloser

internal/dump/dump_test.go:152–175  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func TestDumpRequestBodyWriteCloser(t *testing.T) {
153 var buf bytes.Buffer
154 opt := &testOptions{
155 output: &buf,
156 requestBody: true,
157 requestBodyOut: &buf,
158 }
159 d := NewDumper(opt)
160
161 var inner bytes.Buffer
162 wc := &nopWriteCloser{&inner}
163 wrapped := d.WrapRequestBodyWriteCloser(wc)
164
165 _, err := wrapped.Write([]byte("request body"))
166 if err != nil {
167 t.Fatalf("unexpected error: %v", err)
168 }
169 if buf.String() != "request body" {
170 t.Fatalf("expected 'request body' in dump, got %q", buf.String())
171 }
172 if inner.String() != "request body" {
173 t.Fatalf("expected 'request body' in inner writer, got %q", inner.String())
174 }
175}
176
177func TestGetDumpersWithContext(t *testing.T) {
178 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 4

NewDumperFunction · 0.85
WriteMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…