cmd/promtool: improve output for PromQL tests (#6052)

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
pull/6057/head
Simon Pasquier 5 years ago committed by GitHub
parent e36ab7e192
commit ddff1480a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -321,7 +321,7 @@ Outer:
got, err := query(suite.Context(), testCase.Expr, mint.Add(testCase.EvalTime),
suite.QueryEngine(), suite.Queryable())
if err != nil {
errs = append(errs, errors.Errorf(" expr:'%s', time:%s, err:%s", testCase.Expr,
errs = append(errs, errors.Errorf(" expr: %q, time: %s, err: %s", testCase.Expr,
testCase.EvalTime.String(), err.Error()))
continue
}
@ -338,7 +338,8 @@ Outer:
for _, s := range testCase.ExpSamples {
lb, err := promql.ParseMetric(s.Labels)
if err != nil {
errs = append(errs, errors.Errorf(" expr:'%s', time:%s, err:%s", testCase.Expr,
err = errors.Wrapf(err, "labels %q", s.Labels)
errs = append(errs, errors.Errorf(" expr: %q, time: %s, err: %s", testCase.Expr,
testCase.EvalTime.String(), err.Error()))
continue Outer
}
@ -355,7 +356,7 @@ Outer:
return labels.Compare(gotSamples[i].Labels, gotSamples[j].Labels) <= 0
})
if !reflect.DeepEqual(expSamples, gotSamples) {
errs = append(errs, errors.Errorf(" expr:'%s', time:%s, \n exp:%#v, \n got:%#v", testCase.Expr,
errs = append(errs, errors.Errorf(" expr: %q, time: %s,\n exp:%#v\n got:%#v", testCase.Expr,
testCase.EvalTime.String(), parsedSamplesString(expSamples), parsedSamplesString(gotSamples)))
}
}
@ -510,7 +511,7 @@ func parsedSamplesString(pss []parsedSample) string {
return "nil"
}
s := pss[0].String()
for _, ps := range pss[0:] {
for _, ps := range pss[1:] {
s += ", " + ps.String()
}
return s

Loading…
Cancel
Save