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

Function Test_Hook_OnPreShutdown

hooks_test.go:184–200  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

182}
183
184func Test_Hook_OnPreShutdown(t *testing.T) {
185 t.Parallel()
186 app := New()
187
188 buf := bytebufferpool.Get()
189 defer bytebufferpool.Put(buf)
190
191 app.Hooks().OnPreShutdown(func() error {
192 _, err := buf.WriteString("pre-shutdown")
193 require.NoError(t, err)
194
195 return nil
196 })
197
198 require.NoError(t, app.Shutdown())
199 require.Equal(t, "pre-shutdown", buf.String())
200}
201
202func Test_Hook_OnPostShutdown(t *testing.T) {
203 t.Run("should execute post shutdown hook with error", func(t *testing.T) {

Callers

nothing calls this directly

Calls 8

OnPreShutdownMethod · 0.80
HooksMethod · 0.80
ShutdownMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
PutMethod · 0.65
WriteStringMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected