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

Function Test_App_InitPanicUnlocksRouteRegistration

app_test.go:2316–2355  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2314}
2315
2316func Test_App_InitPanicUnlocksRouteRegistration(t *testing.T) {
2317 t.Parallel()
2318
2319 view := &panicLoadView{}
2320 app := New(Config{Views: view})
2321
2322 type initResult struct {
2323 recovered any
2324 }
2325
2326 initDone := make(chan initResult, 1)
2327 go func() {
2328 result := initResult{}
2329 defer func() {
2330 result.recovered = recover()
2331 initDone <- result
2332 }()
2333
2334 app.init()
2335 }()
2336
2337 select {
2338 case result := <-initDone:
2339 require.Equal(t, "panic load", result.recovered)
2340 case <-time.After(time.Second):
2341 t.Fatal("init panic was not recovered")
2342 }
2343
2344 registerDone := make(chan struct{}, 1)
2345 go func() {
2346 app.Get("/after-panic", func(Ctx) error { return nil })
2347 registerDone <- struct{}{}
2348 }()
2349
2350 select {
2351 case <-registerDone:
2352 case <-time.After(time.Second):
2353 t.Fatal("route registration deadlocked after init panic")
2354 }
2355}
2356
2357func Test_App_RenderPanicUnlocksReloadViews(t *testing.T) {
2358 t.Parallel()

Callers

nothing calls this directly

Calls 4

initMethod · 0.80
NewFunction · 0.70
FatalMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected