(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func 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 | |
| 43 | func TestAttackDuration(t *testing.T) { |
| 44 | t.Parallel() |
nothing calls this directly
no test coverage detected