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

Function Test_ServiceContextProviders

services_test.go:589–616  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

587}
588
589func Test_ServiceContextProviders(t *testing.T) {
590 t.Run("no-provider", func(t *testing.T) {
591 app := &App{
592 configured: Config{},
593 state: newState(),
594 }
595 require.Equal(t, context.Background(), app.servicesStartupCtx())
596 require.Equal(t, context.Background(), app.servicesShutdownCtx())
597 })
598
599 t.Run("with-provider", func(t *testing.T) {
600 ctx := context.TODO()
601 app := &App{
602 configured: Config{
603 ServicesStartupContextProvider: func() context.Context {
604 return ctx
605 },
606 ServicesShutdownContextProvider: func() context.Context {
607 return ctx
608 },
609 },
610 state: newState(),
611 }
612
613 require.Equal(t, ctx, app.servicesStartupCtx())
614 require.Equal(t, ctx, app.servicesShutdownCtx())
615 })
616}
617
618func Benchmark_StartServices(b *testing.B) {
619 benchmarkFn := func(b *testing.B, services []Service) {

Callers

nothing calls this directly

Calls 3

servicesStartupCtxMethod · 0.95
servicesShutdownCtxMethod · 0.95
newStateFunction · 0.85

Tested by

no test coverage detected