From cb806b94be251f3b5c006f6fccb79a168fab2543 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Fri, 7 Jun 2024 12:06:46 +0100 Subject: [PATCH] Add test for response.headerValue --- common/http_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/common/http_test.go b/common/http_test.go index 7b882ae01..f57f78e94 100644 --- a/common/http_test.go +++ b/common/http_test.go @@ -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) + }) +}