MCPcopy
hub / github.com/gofiber/fiber / Test_Response_Status_Code

Function Test_Response_Status_Code

client/response_test.go:73–122  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func Test_Response_Status_Code(t *testing.T) {
74 t.Parallel()
75
76 setupApp := func() *testServer {
77 server := startTestServer(t, func(app *fiber.App) {
78 app.Get("/", func(c fiber.Ctx) error {
79 return c.SendString("foo")
80 })
81 app.Get("/fail", func(c fiber.Ctx) error {
82 return c.SendStatus(407)
83 })
84 })
85
86 return server
87 }
88
89 t.Run("success", func(t *testing.T) {
90 t.Parallel()
91
92 server := setupApp()
93 defer server.stop()
94
95 client := New().SetDial(server.dial())
96
97 resp, err := AcquireRequest().
98 SetClient(client).
99 Get("http://example")
100
101 require.NoError(t, err)
102 require.Equal(t, 200, resp.StatusCode())
103 resp.Close()
104 })
105
106 t.Run("fail", func(t *testing.T) {
107 t.Parallel()
108
109 server := setupApp()
110 defer server.stop()
111
112 client := New().SetDial(server.dial())
113
114 resp, err := AcquireRequest().
115 SetClient(client).
116 Get("http://example/fail")
117
118 require.NoError(t, err)
119 require.Equal(t, 407, resp.StatusCode())
120 resp.Close()
121 })
122}
123
124func Test_Response_Protocol(t *testing.T) {
125 t.Parallel()

Callers

nothing calls this directly

Calls 12

startTestServerFunction · 0.85
AcquireRequestFunction · 0.85
stopMethod · 0.80
dialMethod · 0.80
SetClientMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
SendStringMethod · 0.65
SendStatusMethod · 0.65
SetDialMethod · 0.65
CloseMethod · 0.65
StatusCodeMethod · 0.45

Tested by

no test coverage detected