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

Function Test_Options

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

Source from the content-addressed store, hash-verified

1119}
1120
1121func Test_Options(t *testing.T) {
1122 t.Parallel()
1123
1124 setupApp := func() (*fiber.App, string) {
1125 app, addr := startTestServerWithPort(t, func(app *fiber.App) {
1126 app.Options("/", func(c fiber.Ctx) error {
1127 c.Set(fiber.HeaderAllow, "GET, POST, PUT, DELETE, PATCH")
1128 return c.Status(fiber.StatusNoContent).SendString("")
1129 })
1130 })
1131
1132 return app, addr
1133 }
1134
1135 t.Run("global options function", func(t *testing.T) {
1136 t.Parallel()
1137
1138 app, addr := setupApp()
1139 defer func() {
1140 require.NoError(t, app.Shutdown())
1141 }()
1142
1143 for range 5 {
1144 resp, err := Options("http://" + addr)
1145
1146 require.NoError(t, err)
1147 require.Equal(t, "GET, POST, PUT, DELETE, PATCH", resp.Header(fiber.HeaderAllow))
1148 require.Equal(t, fiber.StatusNoContent, resp.StatusCode())
1149 require.Empty(t, resp.String())
1150 }
1151 })
1152
1153 t.Run("client options", func(t *testing.T) {
1154 t.Parallel()
1155
1156 app, addr := setupApp()
1157 defer func() {
1158 require.NoError(t, app.Shutdown())
1159 }()
1160
1161 for range 5 {
1162 resp, err := New().Options("http://" + addr)
1163
1164 require.NoError(t, err)
1165 require.Equal(t, "GET, POST, PUT, DELETE, PATCH", resp.Header(fiber.HeaderAllow))
1166 require.Equal(t, fiber.StatusNoContent, resp.StatusCode())
1167 require.Empty(t, resp.String())
1168 }
1169 })
1170}
1171
1172func Test_Patch(t *testing.T) {
1173 t.Parallel()

Callers

nothing calls this directly

Calls 11

startTestServerWithPortFunction · 0.85
OptionsFunction · 0.85
ShutdownMethod · 0.80
NewFunction · 0.70
OptionsMethod · 0.65
SetMethod · 0.65
SendStringMethod · 0.65
StatusMethod · 0.65
StringMethod · 0.65
HeaderMethod · 0.45
StatusCodeMethod · 0.45

Tested by

no test coverage detected