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

Function TestAttackRate

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

Source from the content-addressed store, hash-verified

23)
24
25func TestAttackRate(t *testing.T) {
26 t.Parallel()
27 server := httptest.NewServer(
28 http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}),
29 )
30 defer server.Close()
31 tr := NewStaticTargeter(Target{Method: "GET", URL: server.URL})
32 rate := Rate{Freq: 100, Per: time.Second}
33 atk := NewAttacker()
34 var hits uint64
35 for range atk.Attack(tr, rate, 1*time.Second, "") {
36 hits++
37 }
38 if got, want := hits, uint64(rate.Freq); got != want {
39 t.Fatalf("got: %v, want: %v", got, want)
40 }
41}
42
43func TestAttackDuration(t *testing.T) {
44 t.Parallel()

Callers

nothing calls this directly

Calls 4

AttackMethod · 0.95
NewStaticTargeterFunction · 0.85
NewAttackerFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected