Chore: Rewrite some tests to use testify (#28420)

* Chore: Improve tests to use testify

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen
2020-10-21 10:09:42 +02:00
committed by GitHub
parent 97526fc492
commit ec40e49dcb
3 changed files with 29 additions and 69 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
)
func TestCountersAsDelta(t *testing.T) {
@@ -30,14 +31,10 @@ func TestCountersAsDelta(t *testing.T) {
var got float64
want = float64(1)
got = b.replaceCounterWithDelta(mf, m, model.SampleValue(1))
if got != want {
t.Fatalf("want %v got %v", want, got)
}
require.Equal(t, want, got)
got = b.replaceCounterWithDelta(mf, m, model.SampleValue(2))
if got != want {
t.Fatalf("want %v got %v", want, got)
}
require.Equal(t, want, got)
}
func TestCountersAsDeltaDisabled(t *testing.T) {
@@ -56,15 +53,11 @@ func TestCountersAsDeltaDisabled(t *testing.T) {
var got float64
want = float64(1)
got = b.replaceCounterWithDelta(mf, m, model.SampleValue(1))
if got != want {
t.Fatalf("want %v got %v", want, got)
}
require.Equal(t, want, got)
want = float64(2)
got = b.replaceCounterWithDelta(mf, m, model.SampleValue(2))
if got != want {
t.Fatalf("want %v got %v", want, got)
}
require.Equal(t, want, got)
}
func TestSanitize(t *testing.T) {