MCPcopy
hub / github.com/tsenart/vegeta / TestResponseBodyCapture

Function TestResponseBodyCapture

lib/attack_test.go:218–235  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

216}
217
218func TestResponseBodyCapture(t *testing.T) {
219 t.Parallel()
220
221 want := []byte("VEGETA")
222 server := httptest.NewServer(
223 http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
224 w.Write(want)
225 }),
226 )
227 defer server.Close()
228 atk := NewAttacker()
229 tr := NewStaticTargeter(Target{Method: "GET", URL: server.URL})
230
231 res := atk.hit(tr, &attack{name: "", began: time.Now()})
232 if got := res.Body; !bytes.Equal(got, want) {
233 t.Fatalf("got: %v, want: %v", got, want)
234 }
235}
236
237func TestProxyOption(t *testing.T) {
238 t.Parallel()

Callers

nothing calls this directly

Calls 6

hitMethod · 0.95
NewAttackerFunction · 0.85
NewStaticTargeterFunction · 0.85
WriteMethod · 0.80
CloseMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected