diff --git a/backend/app/main_test.go b/backend/app/main_test.go index 7981e1d6..6d5b3320 100644 --- a/backend/app/main_test.go +++ b/backend/app/main_test.go @@ -5,6 +5,7 @@ import ( "log" "net/http" "os" + "os/exec" "strings" "sync" "syscall" @@ -56,3 +57,19 @@ func TestGetDump(t *testing.T) { assert.True(t, strings.Contains(dump, "backend/app/main.go")) log.Print("\n dump:" + dump) } + +func TestCrasher(t *testing.T) { + if os.Getenv("BE_CRASHER") == "1" { + main() + return + } + cmd := exec.Command(os.Args[0], "-test.run=TestCrasher") + cmd.Env = append(os.Environ(), "BE_CRASHER=1") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stdout + err := cmd.Run() + if e, ok := err.(*exec.ExitError); ok && !e.Success() { + return + } + t.Fatalf("process ran with err %v, want exit status 1", err) +}