From b3d60964321a277b1ab2c18d912f204acc30a7c3 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Sun, 6 Jan 2019 00:22:03 +0100 Subject: [PATCH] Improve testutil error messages This also satisfy newer staticcheck versions. Signed-off-by: beorn7 --- prometheus/testutil/testutil.go | 4 +--- prometheus/testutil/testutil_test.go | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/prometheus/testutil/testutil.go b/prometheus/testutil/testutil.go index e344cc8..4c72bc6 100644 --- a/prometheus/testutil/testutil.go +++ b/prometheus/testutil/testutil.go @@ -165,11 +165,9 @@ func compare(got, want []*dto.MetricFamily) error { metric output does not match expectation; want: %s - got: -%s -`, wantBuf.String(), gotBuf.String()) +%s`, wantBuf.String(), gotBuf.String()) } return nil diff --git a/prometheus/testutil/testutil_test.go b/prometheus/testutil/testutil_test.go index 4812247..e1f7aab 100644 --- a/prometheus/testutil/testutil_test.go +++ b/prometheus/testutil/testutil_test.go @@ -171,7 +171,6 @@ func TestCollectAndCompareHistogram(t *testing.T) { c prometheus.Collector metadata string expect string - labels []string observation float64 }{ { @@ -291,13 +290,11 @@ metric output does not match expectation; want: # TYPE some_other_metric counter some_other_metric{label1="value1"} 1.0 - got: # HELP some_total A value that represents a counter. # TYPE some_total counter some_total{label1="value1"} 1.0 - ` err := CollectAndCompare(c, strings.NewReader(metadata+expected)) @@ -306,6 +303,6 @@ some_total{label1="value1"} 1.0 } if err.Error() != expectedError { - t.Errorf("Expected\n%#+v\nGot:\n%#+v\n", expectedError, err.Error()) + t.Errorf("Expected\n%#+v\nGot:\n%#+v", expectedError, err.Error()) } }