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

Function Test_Bind_RespHeader_Map

bind_test.go:1018–1044  ·  view source on GitHub ↗

go test -run Test_Bind_RespHeader_Map -v

(t *testing.T)

Source from the content-addressed store, hash-verified

1016
1017// go test -run Test_Bind_RespHeader_Map -v
1018func Test_Bind_RespHeader_Map(t *testing.T) {
1019 t.Parallel()
1020
1021 app := New()
1022 c := app.AcquireCtx(&fasthttp.RequestCtx{})
1023
1024 c.Request().SetBody([]byte(``))
1025 c.Request().Header.SetContentType("")
1026
1027 c.Response().Header.Add("id", "1")
1028 c.Response().Header.Add("Name", "John Doe")
1029 c.Response().Header.Add("Hobby", "golang,fiber")
1030 q := make(map[string][]string, 0)
1031 require.NoError(t, c.Bind().RespHeader(&q))
1032 require.Len(t, q["Hobby"], 1)
1033
1034 c.Response().Header.Del("hobby")
1035 c.Response().Header.Add("Hobby", "golang,fiber,go")
1036 q = make(map[string][]string, 0)
1037 require.NoError(t, c.Bind().RespHeader(&q))
1038 require.Len(t, q["Hobby"], 1)
1039
1040 empty := make(map[string][]string, 0)
1041 c.Response().Header.Del("hobby")
1042 require.NoError(t, c.Bind().Query(&empty))
1043 require.Empty(t, empty["Hobby"])
1044}
1045
1046// go test -v -run=^$ -bench=Benchmark_Bind_Query -benchmem -count=4
1047func Benchmark_Bind_Query(b *testing.B) {

Callers

nothing calls this directly

Calls 10

AcquireCtxMethod · 0.80
RespHeaderMethod · 0.80
NewFunction · 0.70
RequestMethod · 0.65
AddMethod · 0.65
ResponseMethod · 0.65
BindMethod · 0.65
LenMethod · 0.65
DelMethod · 0.65
QueryMethod · 0.65

Tested by

no test coverage detected