From cb887dee810ea9323290b7f3bd0a24e4c002cadf Mon Sep 17 00:00:00 2001 From: Roman Plessl Date: Thu, 10 Sep 2015 20:35:12 +0200 Subject: [PATCH] change/fix expected test result --- outputs/opentsdb/opentsdb_test.go | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 outputs/opentsdb/opentsdb_test.go diff --git a/outputs/opentsdb/opentsdb_test.go b/outputs/opentsdb/opentsdb_test.go new file mode 100644 index 000000000..bd1bd8f7e --- /dev/null +++ b/outputs/opentsdb/opentsdb_test.go @@ -0,0 +1,53 @@ +package opentsdb + +import ( + "reflect" + "testing" +) + +var ( + fakeHost = "metrics.example.com" + fakePort = 4242 +) + +func fakeOpenTSDB() *OpenTSDB { + var o OpenTSDB + o.Host = fakeHost + o.Port = fakePort + return &o +} + +func TestBuildTagsTelnet(t *testing.T) { + var tagtests = []struct { + bpIn map[string]string + ptIn map[string]string + outTags []string + }{ + { + map[string]string{"one": "two"}, + map[string]string{"three": "four"}, + []string{"one=two", "three=four"}, + }, + { + map[string]string{"aaa": "bbb"}, + map[string]string{}, + []string{"aaa=bbb"}, + }, + { + map[string]string{"one": "two"}, + map[string]string{"aaa": "bbb"}, + []string{"aaa=bbb", "one=two"}, + }, + { + map[string]string{}, + map[string]string{}, + []string{}, + }, + } + for _, tt := range tagtests { + tags := buildTags(tt.bpIn, tt.ptIn) + if !reflect.DeepEqual(tags, tt.outTags) { + t.Errorf("\nexpected %+v\ngot %+v\n", tt.outTags, tags) + } + } +}