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

Function Test_Response_Status

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

Source from the content-addressed store, hash-verified

20)
21
22func Test_Response_Status(t *testing.T) {
23 t.Parallel()
24
25 setupApp := func() *testServer {
26 server := startTestServer(t, func(app *fiber.App) {
27 app.Get("/", func(c fiber.Ctx) error {
28 return c.SendString("foo")
29 })
30 app.Get("/fail", func(c fiber.Ctx) error {
31 return c.SendStatus(407)
32 })
33 })
34
35 return server
36 }
37
38 t.Run("success", func(t *testing.T) {
39 t.Parallel()
40
41 server := setupApp()
42 defer server.stop()
43
44 client := New().SetDial(server.dial())
45
46 resp, err := AcquireRequest().
47 SetClient(client).
48 Get("http://example")
49
50 require.NoError(t, err)
51 require.Equal(t, "OK", resp.Status())
52 resp.Close()
53 })
54
55 t.Run("fail", func(t *testing.T) {
56 t.Parallel()
57
58 server := setupApp()
59 defer server.stop()
60
61 client := New().SetDial(server.dial())
62
63 resp, err := AcquireRequest().
64 SetClient(client).
65 Get("http://example/fail")
66
67 require.NoError(t, err)
68 require.Equal(t, "Proxy Authentication Required", resp.Status())
69 resp.Close()
70 })
71}
72
73func Test_Response_Status_Code(t *testing.T) {
74 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
StatusMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected