mustNotPanic is a helper to enforce that test handlers do not panic (see issue #556).
(t *testing.T, h http.Handler)
| 2464 | // mustNotPanic is a helper to enforce that test handlers do not panic (see |
| 2465 | // issue #556). |
| 2466 | func mustNotPanic(t *testing.T, h http.Handler) http.Handler { |
| 2467 | return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { |
| 2468 | defer func() { |
| 2469 | if r := recover(); r != nil { |
| 2470 | buf := make([]byte, 1<<20) |
| 2471 | n := runtime.Stack(buf, false) |
| 2472 | fmt.Fprintf(os.Stderr, "handler panic: %v\n\n%s", r, buf[:n]) |
| 2473 | t.Errorf("handler panicked: %v", r) |
| 2474 | } |
| 2475 | }() |
| 2476 | h.ServeHTTP(w, req) |
| 2477 | }) |
| 2478 | } |
| 2479 | |
| 2480 | // TestPingEventFiltering verifies that the streamable client correctly filters |
| 2481 | // out SSE "ping" events, which are used for keep-alive but should not be |
no test coverage detected
searching dependent graphs…