Skip to content

Commit

Permalink
apply review
Browse files Browse the repository at this point in the history
  • Loading branch information
efectn committed Mar 2, 2024
1 parent 9bf3d34 commit f56dfd2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
20 changes: 20 additions & 0 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,26 @@ func Test_Client_CookieJar_Response(t *testing.T) {
}
}
})

t.Run("different domain", func(t *testing.T) {
t.Parallel()
handler := func(c fiber.Ctx) error {
return c.SendString(c.Cookies("k1"))
}

jar := AcquireCookieJar()
defer ReleaseCookieJar(jar)

jar.SetKeyValue("example.com", "k1", "v1")

wrapAgent := func(c *Client) {
c.SetCookieJar(jar)
}
testClient(t, handler, wrapAgent, "v1")

require.Len(t, jar.getCookiesByHost("example.com"), 1)
require.Len(t, jar.getCookiesByHost("example"), 0)
})
}

func Test_Client_Referer(t *testing.T) {
Expand Down
11 changes: 7 additions & 4 deletions listen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ func Test_Listen_Graceful_Shutdown(t *testing.T) {
Time time.Duration
ExpectedBody string
ExpectedStatusCode int
ExceptedErr error
ExpectedErr error
}{
{Time: 100 * time.Millisecond, ExpectedBody: "example.com", ExpectedStatusCode: StatusOK, ExceptedErr: nil},
{Time: 500 * time.Millisecond, ExpectedBody: "", ExpectedStatusCode: StatusOK, ExceptedErr: errors.New("InmemoryListener is already closed: use of closed network connection")},
{Time: 100 * time.Millisecond, ExpectedBody: "example.com", ExpectedStatusCode: StatusOK, ExpectedErr: nil},
{Time: 500 * time.Millisecond, ExpectedBody: "", ExpectedStatusCode: StatusOK, ExpectedErr: errors.New("InmemoryListener is already closed: use of closed network connection")},
}

for _, tc := range testCases {
Expand All @@ -87,9 +87,12 @@ func Test_Listen_Graceful_Shutdown(t *testing.T) {
resp := fasthttp.AcquireResponse()
err := client.Do(req, resp)

require.Equal(t, tc.ExceptedErr, err)
require.Equal(t, tc.ExpectedErr, err)
require.Equal(t, tc.ExpectedStatusCode, resp.StatusCode())
require.Equal(t, tc.ExpectedBody, string(resp.Body()))

fasthttp.ReleaseRequest(req)
fasthttp.ReleaseResponse(resp)
}

mu.Lock()
Expand Down
8 changes: 4 additions & 4 deletions redirect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,28 +291,28 @@ func Test_Redirect_Request(t *testing.T) {
CookieValue string
ExpectedBody string
ExpectedStatusCode int
ExceptedErr error
ExpectedErr error
}{
{
URL: "/",
CookieValue: "key:value,key2:value2,co\\:m\\,ma:Fi\\:ber\\, v3",
ExpectedBody: `{"inputs":{},"messages":{"co:m,ma":"Fi:ber, v3","key":"value","key2":"value2"}}`,
ExpectedStatusCode: StatusOK,
ExceptedErr: nil,
ExpectedErr: nil,
},
{
URL: "/with-inputs?name=john&surname=doe",
CookieValue: "key:value,key2:value2,key:value,key2:value2,old_input_data_name:john,old_input_data_surname:doe",
ExpectedBody: `{"inputs":{"name":"john","surname":"doe"},"messages":{"key":"value","key2":"value2"}}`,
ExpectedStatusCode: StatusOK,
ExceptedErr: nil,
ExpectedErr: nil,
},
{
URL: "/just-inputs?name=john&surname=doe",
CookieValue: "old_input_data_name:john,old_input_data_surname:doe",
ExpectedBody: `{"inputs":{"name":"john","surname":"doe"},"messages":{}}`,
ExpectedStatusCode: StatusOK,
ExceptedErr: nil,
ExpectedErr: nil,
},
}

Expand Down

0 comments on commit f56dfd2

Please sign in to comment.