Skip to content

Commit

Permalink
move wrapper for metric float comparision to common (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranakan19 authored Aug 15, 2024
1 parent 14c41a9 commit a209f6c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/test/metrics/metric.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package metrics

import (
"testing"

"github.com/prometheus/client_golang/prometheus"
promtestutil "github.com/prometheus/client_golang/prometheus/testutil"
"github.com/stretchr/testify/assert"
)

func AssertMetricsCounterEquals(t *testing.T, expected int, c prometheus.Counter) {
assert.InDelta(t, float64(expected), promtestutil.ToFloat64(c), 0.01)
}

func AssertMetricsGaugeEquals(t *testing.T, expected int, g prometheus.Gauge, msgAndArgs ...interface{}) {
assert.InDelta(t, float64(expected), promtestutil.ToFloat64(g), 0.01, msgAndArgs...)
}

0 comments on commit a209f6c

Please sign in to comment.