Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdurham committed Jan 13, 2025
1 parent 2596211 commit 76d21b2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/component/prometheus/relabel/relabel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package relabel

import (
"fmt"
dto "github.com/prometheus/client_model/go"
"math"
"strconv"
"testing"
Expand Down Expand Up @@ -111,6 +112,17 @@ func TestLRUNaN(t *testing.T) {
require.True(t, relabeller.cache.Len() == 0)
}

func TestMetrics(t *testing.T) {
relabeller := generateRelabel(t)
lbls := labels.FromStrings("__address__", "localhost")

relabeller.relabel(0, lbls)
m := &dto.Metric{}
err := relabeller.metricsProcessed.Write(m)
require.NoError(t, err)
require.True(t, *(m.Counter.Value) == 1)
}

func BenchmarkCache(b *testing.B) {
ls := labelstore.New(nil, prom.DefaultRegisterer)
fanout := prometheus.NewInterceptor(nil, ls, prometheus.WithAppendHook(func(ref storage.SeriesRef, l labels.Labels, _ int64, _ float64, _ storage.Appender) (storage.SeriesRef, error) {
Expand Down

0 comments on commit 76d21b2

Please sign in to comment.