Skip to content

Commit

Permalink
Add test for response.headerValue
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur22 committed Jun 7, 2024
1 parent fe5637e commit cb806b9
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions common/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,35 @@ func TestRequest(t *testing.T) {
req.Size())
})
}

func TestResponse(t *testing.T) {
t.Parallel()

ts := cdp.MonotonicTime(time.Now())
headers := map[string]any{"key": "value"}
vu := k6test.NewVU(t)
vu.ActivateVU()
req := &Request{
offset: 0,
}
res := NewHTTPResponse(vu.Context(), req, &network.Response{
URL: "https://test/post",
Headers: network.Headers(headers),
}, &ts)

t.Run("HeaderValue()_key", func(t *testing.T) {
t.Parallel()

got, ok := res.HeaderValue("key")
assert.True(t, ok)
assert.Equal(t, "value", got)
})

t.Run("HeaderValue()_KEY", func(t *testing.T) {
t.Parallel()

got, ok := res.HeaderValue("KEY")
assert.True(t, ok)
assert.Equal(t, "value", got)
})
}

0 comments on commit cb806b9

Please sign in to comment.