Skip to content

Commit

Permalink
test transform metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Porter <portertech@gmail.com>
  • Loading branch information
portertech committed Aug 19, 2020
1 parent a91619c commit f364c57
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ import (
"github.com/stretchr/testify/require"
)

func TestTransformMetrics(t *testing.T) {
assert := assert.New(t)
event := corev2.FixtureEvent("entity1", "check1")
event.Check = nil
event.Metrics = corev2.FixtureMetrics()
plugin.DefaultType = "untyped"
job, inst, m := transformMetrics(event)
em := "# TYPE answer untyped\nanswer{foo=\"bar\"} 42\n"
assert.Contains(m, em)
assert.Equal(job, "")
assert.Equal(inst, "")
plugin.DefaultType = "gauge"
plugin.DefaultJob = "foo"
plugin.DefaultInstance = "bar"
job, inst, m = transformMetrics(event)
em = "# TYPE answer gauge\nanswer{foo=\"bar\"} 42\n"
assert.Contains(m, em)
assert.Equal(job, "foo")
assert.Equal(inst, "bar")
}

func TestPostMetrics(t *testing.T) {
assert := assert.New(t)

Expand Down

0 comments on commit f364c57

Please sign in to comment.