Handle runtime errors as fatal test results

This commit is contained in:
David Kaltschmidt 2017-11-19 21:15:24 +01:00
parent 3c5d207a53
commit 8e01e7e388
1 changed files with 8 additions and 2 deletions

View File

@ -47,9 +47,15 @@ func TestQueryStatsWithTimers(t *testing.T) {
var qs *QueryStats
qs = NewQueryStats(tg)
actual, _ := json.Marshal(qs)
actual, err := json.Marshal(qs)
if err != nil {
t.Fatalf("Unexpected error during serialization: %v", err)
}
// Timing value is one of multiple fields, unit is seconds (float).
match, _ := regexp.MatchString(`[,{]"execTotalTime":\d+\.\d+[,}]`, string(actual))
match, err := regexp.MatchString(`[,{]"execTotalTime":\d+\.\d+[,}]`, string(actual))
if err != nil {
t.Fatalf("Unexpected error while matching string: %v", err)
}
if !match {
t.Fatalf("Expected timings with one non-zero entry, but got %s.", actual)
}