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

Function Test_Put

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

Source from the content-addressed store, hash-verified

1004}
1005
1006func Test_Put(t *testing.T) {
1007 t.Parallel()
1008
1009 setupApp := func() (*fiber.App, string) {
1010 app, addr := startTestServerWithPort(t, func(app *fiber.App) {
1011 app.Put("/", func(c fiber.Ctx) error {
1012 return c.SendString(c.FormValue("foo"))
1013 })
1014 })
1015
1016 return app, addr
1017 }
1018
1019 t.Run("global put function", func(t *testing.T) {
1020 t.Parallel()
1021
1022 app, addr := setupApp()
1023 defer func() {
1024 require.NoError(t, app.Shutdown())
1025 }()
1026
1027 for range 5 {
1028 resp, err := Put("http://"+addr, Config{
1029 FormData: map[string]string{
1030 "foo": "bar",
1031 },
1032 })
1033
1034 require.NoError(t, err)
1035 require.Equal(t, fiber.StatusOK, resp.StatusCode())
1036 require.Equal(t, "bar", resp.String())
1037 }
1038 })
1039
1040 t.Run("client put", func(t *testing.T) {
1041 t.Parallel()
1042
1043 app, addr := setupApp()
1044 defer func() {
1045 require.NoError(t, app.Shutdown())
1046 }()
1047
1048 for range 5 {
1049 resp, err := New().Put("http://"+addr, Config{
1050 FormData: map[string]string{
1051 "foo": "bar",
1052 },
1053 })
1054
1055 require.NoError(t, err)
1056 require.Equal(t, fiber.StatusOK, resp.StatusCode())
1057 require.Equal(t, "bar", resp.String())
1058 }
1059 })
1060}
1061
1062func Test_Delete(t *testing.T) {
1063 t.Parallel()

Callers

nothing calls this directly

Calls 9

startTestServerWithPortFunction · 0.85
PutFunction · 0.85
ShutdownMethod · 0.80
NewFunction · 0.70
PutMethod · 0.65
SendStringMethod · 0.65
FormValueMethod · 0.65
StringMethod · 0.65
StatusCodeMethod · 0.45

Tested by

no test coverage detected