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

Function TestLocalAddr

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

Source from the content-addressed store, hash-verified

132}
133
134func TestLocalAddr(t *testing.T) {
135 t.Parallel()
136 addr, err := net.ResolveIPAddr("ip", "127.0.0.1")
137 if err != nil {
138 t.Fatal(err)
139 }
140 server := httptest.NewServer(
141 http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
142 if got, _, err := net.SplitHostPort(r.RemoteAddr); err != nil {
143 t.Fatal(err)
144 } else if want := addr.String(); got != want {
145 t.Fatalf("wrong source address. got %v, want: %v", got, want)
146 }
147 }),
148 )
149 defer server.Close()
150 atk := NewAttacker(LocalAddr(*addr))
151 tr := NewStaticTargeter(Target{Method: "GET", URL: server.URL})
152 atk.hit(tr, &attack{name: "", began: time.Now()})
153
154}
155
156func TestKeepAlive(t *testing.T) {
157 t.Parallel()

Callers

nothing calls this directly

Calls 6

hitMethod · 0.95
NewAttackerFunction · 0.85
LocalAddrFunction · 0.85
NewStaticTargeterFunction · 0.85
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected