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

Function Test_Patch

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

Source from the content-addressed store, hash-verified

1170}
1171
1172func Test_Patch(t *testing.T) {
1173 t.Parallel()
1174
1175 setupApp := func() (*fiber.App, string) {
1176 app, addr := startTestServerWithPort(t, func(app *fiber.App) {
1177 app.Patch("/", func(c fiber.Ctx) error {
1178 return c.SendString(c.FormValue("foo"))
1179 })
1180 })
1181
1182 return app, addr
1183 }
1184
1185 t.Run("global patch function", func(t *testing.T) {
1186 t.Parallel()
1187
1188 app, addr := setupApp()
1189 defer func() {
1190 require.NoError(t, app.Shutdown())
1191 }()
1192
1193 time.Sleep(1 * time.Second)
1194
1195 for range 5 {
1196 resp, err := Patch("http://"+addr, Config{
1197 FormData: map[string]string{
1198 "foo": "bar",
1199 },
1200 })
1201
1202 require.NoError(t, err)
1203 require.Equal(t, fiber.StatusOK, resp.StatusCode())
1204 require.Equal(t, "bar", resp.String())
1205 }
1206 })
1207
1208 t.Run("client patch", func(t *testing.T) {
1209 t.Parallel()
1210
1211 app, addr := setupApp()
1212 defer func() {
1213 require.NoError(t, app.Shutdown())
1214 }()
1215
1216 for range 5 {
1217 resp, err := New().Patch("http://"+addr, Config{
1218 FormData: map[string]string{
1219 "foo": "bar",
1220 },
1221 })
1222
1223 require.NoError(t, err)
1224 require.Equal(t, fiber.StatusOK, resp.StatusCode())
1225 require.Equal(t, "bar", resp.String())
1226 }
1227 })
1228}
1229

Callers

nothing calls this directly

Calls 9

startTestServerWithPortFunction · 0.85
PatchFunction · 0.85
ShutdownMethod · 0.80
NewFunction · 0.70
PatchMethod · 0.65
SendStringMethod · 0.65
FormValueMethod · 0.65
StringMethod · 0.65
StatusCodeMethod · 0.45

Tested by

no test coverage detected