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

Function Test_Client_Logger_Debug

client/hooks_test.go:686–721  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

684func (*dummyLogger) Panicw(_ string, _ ...any) {}
685
686func Test_Client_Logger_Debug(t *testing.T) {
687 t.Parallel()
688 app := fiber.New()
689 app.Get("/", func(c fiber.Ctx) error {
690 return c.SendString("response")
691 })
692
693 addrChan := make(chan string)
694 go func() {
695 assert.NoError(t, app.Listen(":0", fiber.ListenConfig{
696 DisableStartupMessage: true,
697 ListenerAddrFunc: func(addr net.Addr) {
698 addrChan <- addr.String()
699 },
700 }))
701 }()
702
703 defer func(app *fiber.App) {
704 require.NoError(t, app.Shutdown())
705 }(app)
706
707 var buf bytes.Buffer
708 logger := &dummyLogger{buf: &buf}
709
710 client := New()
711 client.Debug().SetLogger(logger)
712
713 addr := <-addrChan
714 resp, err := client.Get("http://" + addr)
715 require.NoError(t, err)
716 defer resp.Close()
717
718 require.NoError(t, err)
719 require.Contains(t, buf.String(), "Host: "+addr)
720 require.Contains(t, buf.String(), "Content-Length: 8")
721}
722
723func Test_Client_Logger_DisableDebug(t *testing.T) {
724 t.Parallel()

Callers

nothing calls this directly

Calls 12

StringMethod · 0.95
ListenMethod · 0.80
ShutdownMethod · 0.80
SetLoggerMethod · 0.80
ContainsMethod · 0.80
NewFunction · 0.70
NewMethod · 0.65
GetMethod · 0.65
SendStringMethod · 0.65
StringMethod · 0.65
DebugMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected