Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Fix riemann output unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc authored and mlinde201 committed Feb 6, 2017
1 parent dc9e503 commit 61a3117
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions plugins/outputs/riemann/riemann_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/amir/raidman"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/metric"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -72,14 +73,14 @@ func TestMetricEvents(t *testing.T) {
}

// build a single event
metric, _ := telegraf.NewMetric(
m, _ := metric.New(
"test1",
map[string]string{"tag1": "value1", "host": "abc123"},
map[string]interface{}{"value": 5.6},
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
)

events := r.buildRiemannEvents(metric)
events := r.buildRiemannEvents(m)
require.Len(t, events, 1)

// is event as expected?
Expand All @@ -97,14 +98,14 @@ func TestMetricEvents(t *testing.T) {
require.Equal(t, expectedEvent, events[0])

// build 2 events
metric, _ = telegraf.NewMetric(
m, _ = metric.New(
"test2",
map[string]string{"host": "xyz987"},
map[string]interface{}{"point": 1},
time.Date(2012, time.November, 2, 3, 0, 0, 0, time.UTC),
)

events = append(events, r.buildRiemannEvents(metric)...)
events = append(events, r.buildRiemannEvents(m)...)
require.Len(t, events, 2)

// first event should still be the same
Expand All @@ -131,20 +132,20 @@ func TestStateEvents(t *testing.T) {
}

// string metrics will be skipped unless explicitly enabled
metric, _ := telegraf.NewMetric(
m, _ := metric.New(
"test",
map[string]string{"host": "host"},
map[string]interface{}{"value": "running"},
time.Date(2015, time.November, 9, 22, 0, 0, 0, time.UTC),
)

events := r.buildRiemannEvents(metric)
events := r.buildRiemannEvents(m)
// no event should be present
require.Len(t, events, 0)

// enable string metrics as event states
r.StringAsState = true
events = r.buildRiemannEvents(metric)
events = r.buildRiemannEvents(m)
require.Len(t, events, 1)

// is event as expected?
Expand Down

0 comments on commit 61a3117

Please sign in to comment.