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

Function TestRedirects

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

Source from the content-addressed store, hash-verified

73}
74
75func TestRedirects(t *testing.T) {
76 t.Parallel()
77 server := httptest.NewServer(
78 http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
79 http.Redirect(w, r, "/redirect", 302)
80 }),
81 )
82 defer server.Close()
83 redirects := 2
84 atk := NewAttacker(Redirects(redirects))
85 tr := NewStaticTargeter(Target{Method: "GET", URL: server.URL})
86 res := atk.hit(tr, &attack{name: "", began: time.Now()})
87 want := fmt.Sprintf("stopped after %d redirects", redirects)
88 if got := res.Error; !strings.HasSuffix(got, want) {
89 t.Fatalf("want: '%v' in '%v'", want, got)
90 }
91}
92
93func TestNoFollow(t *testing.T) {
94 t.Parallel()

Callers

nothing calls this directly

Calls 5

hitMethod · 0.95
NewAttackerFunction · 0.85
RedirectsFunction · 0.85
NewStaticTargeterFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected