From 10f19fade140a92496fd188f4f3b689bea0df4e5 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Wed, 6 Jan 2016 18:19:18 -0700 Subject: [PATCH] 0.3.0 unit tests: statsd, trig, zookeeper --- plugins/statsd/statsd_test.go | 10 ++++------ plugins/trig/trig_test.go | 5 +---- plugins/zookeeper/zookeeper_test.go | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/plugins/statsd/statsd_test.go b/plugins/statsd/statsd_test.go index 6c85b0c4b..4a97728f2 100644 --- a/plugins/statsd/statsd_test.go +++ b/plugins/statsd/statsd_test.go @@ -647,7 +647,7 @@ func TestParse_Counters(t *testing.T) { func TestParse_Timings(t *testing.T) { s := NewStatsd() s.Percentiles = []int{90} - testacc := &testutil.Accumulator{} + acc := &testutil.Accumulator{} // Test that counters work valid_lines := []string{ @@ -665,7 +665,7 @@ func TestParse_Timings(t *testing.T) { } } - s.Gather(testacc) + s.Gather(acc) tests := []struct { name string @@ -698,10 +698,8 @@ func TestParse_Timings(t *testing.T) { } for _, test := range tests { - if !testacc.CheckValue(test.name, test.value) { - t.Errorf("Did not find measurement %s with value %v", - test.name, test.value) - } + acc.AssertContainsFields(t, test.name, + map[string]interface{}{"value": test.value}) } } diff --git a/plugins/trig/trig_test.go b/plugins/trig/trig_test.go index 24218fe11..82605b0a5 100644 --- a/plugins/trig/trig_test.go +++ b/plugins/trig/trig_test.go @@ -5,8 +5,6 @@ import ( "testing" "github.com/influxdb/telegraf/testutil" - "github.com/stretchr/testify/assert" - // "github.com/stretchr/testify/require" ) func TestTrig(t *testing.T) { @@ -27,7 +25,6 @@ func TestTrig(t *testing.T) { fields["sine"] = sine fields["cosine"] = cosine - assert.True(t, acc.CheckFieldsValue("trig", fields)) - + acc.AssertContainsFields(t, "trig", fields) } } diff --git a/plugins/zookeeper/zookeeper_test.go b/plugins/zookeeper/zookeeper_test.go index 075ca521d..354382ecc 100644 --- a/plugins/zookeeper/zookeeper_test.go +++ b/plugins/zookeeper/zookeeper_test.go @@ -38,6 +38,6 @@ func TestZookeeperGeneratesMetrics(t *testing.T) { } for _, metric := range intMetrics { - assert.True(t, acc.HasIntValue(metric), metric) + assert.True(t, acc.HasIntField("zookeeper", metric), metric) } }