mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:04:39 +03:00
Fail tests if unhandled panics happened.
We normally recover from those situations, printing stack traces instead of crashing the program. But during tests, we're not looking at the prometheus metrics or all the output. Without these checks, such panics could go unnoticed. Seems like a reasonable thing to add, unhandled panics haven't been encountered in tests.
This commit is contained in:
17
webaccount/main_test.go
Normal file
17
webaccount/main_test.go
Normal file
@ -0,0 +1,17 @@
|
||||
package webaccount
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/mjl-/mox/metrics"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
m.Run()
|
||||
if metrics.Panics.Load() > 0 {
|
||||
fmt.Println("unhandled panics encountered")
|
||||
os.Exit(2)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user