diff --git a/server_test.go b/server_test.go index 6cd328a5..a12dc293 100644 --- a/server_test.go +++ b/server_test.go @@ -629,6 +629,10 @@ func checkInProgressQueriesAtShutdownServer(t *testing.T, srv *Server, addr stri wg.Add(requests) var errOnce sync.Once + // t.Fail will panic if it's called after the test function has + // finished. Burning the sync.Once with a defer will prevent the + // handler from calling t.Errorf after we've returned. + defer errOnce.Do(func() {}) HandleFunc("example.com.", func(w ResponseWriter, req *Msg) { defer wg.Done()