(t *testing.T)
| 110 | } |
| 111 | |
| 112 | func TestTimeout(t *testing.T) { |
| 113 | t.Parallel() |
| 114 | server := httptest.NewServer( |
| 115 | http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 116 | <-time.After(20 * time.Millisecond) |
| 117 | }), |
| 118 | ) |
| 119 | defer server.Close() |
| 120 | atk := NewAttacker(Timeout(10 * time.Millisecond)) |
| 121 | tr := NewStaticTargeter(Target{Method: "GET", URL: server.URL}) |
| 122 | res := atk.hit(tr, &attack{name: "", began: time.Now()}) |
| 123 | |
| 124 | want := "Client.Timeout exceeded while awaiting headers" |
| 125 | if got := res.Error; !strings.Contains(got, want) { |
| 126 | t.Fatalf("want: '%v' in '%v'", want, got) |
| 127 | } |
| 128 | |
| 129 | if res.Latency == 0 { |
| 130 | t.Fatal("Latency wasn't captured with a timed-out result") |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | func TestLocalAddr(t *testing.T) { |
| 135 | t.Parallel() |
nothing calls this directly
no test coverage detected