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

Function Test_Get

client/client_test.go:867–905  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

865}
866
867func Test_Get(t *testing.T) {
868 t.Parallel()
869
870 setupApp := func() (*fiber.App, string) {
871 app, addr := startTestServerWithPort(t, func(app *fiber.App) {
872 app.Get("/", func(c fiber.Ctx) error {
873 return c.SendString(c.Hostname())
874 })
875 })
876
877 return app, addr
878 }
879
880 t.Run("global get function", func(t *testing.T) {
881 t.Parallel()
882
883 app, addr := setupApp()
884 defer func() {
885 require.NoError(t, app.Shutdown())
886 }()
887
888 resp, err := Get("http://" + addr)
889 require.NoError(t, err)
890 require.Equal(t, "0.0.0.0", utils.UnsafeString(resp.RawResponse.Body()))
891 })
892
893 t.Run("client get", func(t *testing.T) {
894 t.Parallel()
895
896 app, addr := setupApp()
897 defer func() {
898 require.NoError(t, app.Shutdown())
899 }()
900
901 resp, err := New().Get("http://" + addr)
902 require.NoError(t, err)
903 require.Equal(t, "0.0.0.0", utils.UnsafeString(resp.RawResponse.Body()))
904 })
905}
906
907func Test_Head(t *testing.T) {
908 t.Parallel()

Callers

nothing calls this directly

Calls 8

startTestServerWithPortFunction · 0.85
GetFunction · 0.85
ShutdownMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
SendStringMethod · 0.65
HostnameMethod · 0.65
BodyMethod · 0.65

Tested by

no test coverage detected