mirror of https://github.com/prometheus/prometheus
Handle runtime errors as fatal test results
parent
3c5d207a53
commit
8e01e7e388
|
@ -47,9 +47,15 @@ func TestQueryStatsWithTimers(t *testing.T) {
|
||||||
|
|
||||||
var qs *QueryStats
|
var qs *QueryStats
|
||||||
qs = NewQueryStats(tg)
|
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).
|
// 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 {
|
if !match {
|
||||||
t.Fatalf("Expected timings with one non-zero entry, but got %s.", actual)
|
t.Fatalf("Expected timings with one non-zero entry, but got %s.", actual)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue