Home / Function/ Test_Exec_Func() — fiber Function Reference

Test_Exec_Func() — fiber Function Reference

Architecture documentation for the Test_Exec_Func() function in core_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  505f6813_bc9c_72d4_f02e_5e2681a18c5e["Test_Exec_Func()"]
  35aff514_5856_8aa3_8f9e_63a5c957346d["core_test.go"]
  505f6813_bc9c_72d4_f02e_5e2681a18c5e -->|defined in| 35aff514_5856_8aa3_8f9e_63a5c957346d
  cfe157b9_c254_7ddf_895e_56fcba4ec095["newBlockingErrTransport()"]
  505f6813_bc9c_72d4_f02e_5e2681a18c5e -->|calls| cfe157b9_c254_7ddf_895e_56fcba4ec095
  style 505f6813_bc9c_72d4_f02e_5e2681a18c5e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

client/core_test.go lines 64–214

func Test_Exec_Func(t *testing.T) {
	t.Parallel()
	ln := fasthttputil.NewInmemoryListener()
	app := fiber.New()

	app.Get("/normal", func(c fiber.Ctx) error {
		return c.SendString(c.Hostname())
	})

	app.Get("/return-error", func(_ fiber.Ctx) error {
		return errors.New("the request is error")
	})

	app.Get("/redirect", func(c fiber.Ctx) error {
		return c.Redirect().Status(fiber.StatusFound).To("/normal")
	})

	app.Get("/hang-up", func(c fiber.Ctx) error {
		time.Sleep(time.Second)
		return c.SendString(c.Hostname() + " hang up")
	})

	go func() {
		assert.NoError(t, app.Listener(ln, fiber.ListenConfig{DisableStartupMessage: true}))
	}()

	time.Sleep(300 * time.Millisecond)

	t.Run("normal request", func(t *testing.T) {
		t.Parallel()
		core, client, req := newCore(), New(), AcquireRequest()
		core.ctx = context.Background()
		core.client = client
		core.req = req

		client.SetDial(func(_ string) (net.Conn, error) { return ln.Dial() })
		req.RawRequest.SetRequestURI("http://example.com/normal")

		resp, err := core.execFunc()
		require.NoError(t, err)
		require.Equal(t, 200, resp.RawResponse.StatusCode())
		require.Equal(t, "example.com", string(resp.RawResponse.Body()))
	})

	t.Run("follow redirect with retry config", func(t *testing.T) {
		t.Parallel()
		core, client, req := newCore(), New(), AcquireRequest()
		core.ctx = context.Background()
		core.client = client
		core.req = req

		client.SetRetryConfig(&RetryConfig{MaxRetryCount: 1})
		client.SetDial(func(_ string) (net.Conn, error) { return ln.Dial() })
		req.SetMaxRedirects(1)
		req.RawRequest.Header.SetMethod(fiber.MethodGet)
		req.RawRequest.SetRequestURI("http://example.com/redirect")

		resp, err := core.execFunc()
		require.NoError(t, err)
		require.Equal(t, 200, resp.RawResponse.StatusCode())
		require.Equal(t, "example.com", string(resp.RawResponse.Body()))
	})

	t.Run("the request return an error", func(t *testing.T) {
		t.Parallel()
		core, client, req := newCore(), New(), AcquireRequest()
		core.ctx = context.Background()
		core.client = client
		core.req = req

		client.SetDial(func(_ string) (net.Conn, error) { return ln.Dial() })
		req.RawRequest.SetRequestURI("http://example.com/return-error")

		resp, err := core.execFunc()

		require.NoError(t, err)
		require.Equal(t, 500, resp.RawResponse.StatusCode())
		require.Equal(t, "the request is error", string(resp.RawResponse.Body()))
	})

	t.Run("the request timeout", func(t *testing.T) {

Domain

Subdomains

Defined In

Frequently Asked Questions

What does Test_Exec_Func() do?
Test_Exec_Func() is a function in the fiber codebase, defined in client/core_test.go.
Where is Test_Exec_Func() defined?
Test_Exec_Func() is defined in client/core_test.go at line 64.
What does Test_Exec_Func() call?
Test_Exec_Func() calls 1 function(s): newBlockingErrTransport.

Analyze Your Own Codebase

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

Try Supermodel Free