Home / Function/ Test_Client_CookieJar_Response() — fiber Function Reference

Test_Client_CookieJar_Response() — fiber Function Reference

Architecture documentation for the Test_Client_CookieJar_Response() function in client_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  00ddad81_af63_3eee_cb39_ef025933a7bf["Test_Client_CookieJar_Response()"]
  5d11d0f7_2b3b_7bf3_3b1d_76d79d6872a2["client_test.go"]
  00ddad81_af63_3eee_cb39_ef025933a7bf -->|defined in| 5d11d0f7_2b3b_7bf3_3b1d_76d79d6872a2
  style 00ddad81_af63_3eee_cb39_ef025933a7bf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

client/client_test.go lines 1483–1587

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

	t.Run("without expiration", func(t *testing.T) {
		t.Parallel()
		handler := func(c fiber.Ctx) error {
			c.Cookie(&fiber.Cookie{
				Name:  "k4",
				Value: "v4",
			})
			return c.SendString(
				c.Cookies("k1") + c.Cookies("k2") + c.Cookies("k3"))
		}

		jar := AcquireCookieJar()
		defer ReleaseCookieJar(jar)

		jar.SetKeyValue("example.com", "k1", "v1")
		jar.SetKeyValue("example.com", "k2", "v2")
		jar.SetKeyValue("example", "k3", "v3")

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

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

	t.Run("with expiration", func(t *testing.T) {
		t.Parallel()
		handler := func(c fiber.Ctx) error {
			c.Cookie(&fiber.Cookie{
				Name:    "k4",
				Value:   "v4",
				Expires: time.Now().Add(1 * time.Nanosecond),
			})
			return c.SendString(
				c.Cookies("k1") + c.Cookies("k2") + c.Cookies("k3"))
		}

		jar := AcquireCookieJar()
		defer ReleaseCookieJar(jar)

		jar.SetKeyValue("example.com", "k1", "v1")
		jar.SetKeyValue("example.com", "k2", "v2")
		jar.SetKeyValue("example", "k3", "v3")

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

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

	t.Run("override cookie value", func(t *testing.T) {
		t.Parallel()
		handler := func(c fiber.Ctx) error {
			c.Cookie(&fiber.Cookie{
				Name:  "k1",
				Value: "v2",
			})
			return c.SendString(
				c.Cookies("k1") + c.Cookies("k2"))
		}

		jar := AcquireCookieJar()
		defer ReleaseCookieJar(jar)

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

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

		for _, cookie := range jar.getCookiesByHost("example.com") {
			if string(cookie.Key()) == "k1" {
				require.Equal(t, "v2", string(cookie.Value()))

Domain

Subdomains

Frequently Asked Questions

What does Test_Client_CookieJar_Response() do?
Test_Client_CookieJar_Response() is a function in the fiber codebase, defined in client/client_test.go.
Where is Test_Client_CookieJar_Response() defined?
Test_Client_CookieJar_Response() is defined in client/client_test.go at line 1483.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free