From 4fdcb136bcc5d282ed5e3daaabf1b51c23356769 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Thu, 7 Jan 2016 10:23:38 -0700 Subject: [PATCH] 0.3.0 unit tests: internal --- internal/config/config_test.go | 22 +++++++------------ internal/config/testdata/subconfig/exec.conf | 2 -- .../config/testdata/subconfig/procstat.conf | 3 --- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index f6b929976..eeb1f7fae 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -39,6 +39,7 @@ func TestConfig_LoadSinglePlugin(t *testing.T) { }, Interval: 5 * time.Second, } + mConfig.Tags = make(map[string]string) assert.Equal(t, memcached, c.Plugins[0].Plugin, "Testdata did not produce a correct memcached struct.") @@ -81,19 +82,18 @@ func TestConfig_LoadDirectory(t *testing.T) { }, Interval: 5 * time.Second, } + mConfig.Tags = make(map[string]string) + assert.Equal(t, memcached, c.Plugins[0].Plugin, "Testdata did not produce a correct memcached struct.") assert.Equal(t, mConfig, c.Plugins[0].Config, "Testdata did not produce correct memcached metadata.") ex := plugins.Plugins["exec"]().(*exec.Exec) - ex.Commands = []*exec.Command{ - &exec.Command{ - Command: "/usr/bin/myothercollector --foo=bar", - Name: "myothercollector", - }, - } + ex.Command = "/usr/bin/myothercollector --foo=bar" + ex.Name = "myothercollector" eConfig := &PluginConfig{Name: "exec"} + eConfig.Tags = make(map[string]string) assert.Equal(t, ex, c.Plugins[1].Plugin, "Merged Testdata did not produce a correct exec struct.") assert.Equal(t, eConfig, c.Plugins[1].Config, @@ -106,16 +106,10 @@ func TestConfig_LoadDirectory(t *testing.T) { "Testdata did not produce correct memcached metadata.") pstat := plugins.Plugins["procstat"]().(*procstat.Procstat) - pstat.Specifications = []*procstat.Specification{ - &procstat.Specification{ - PidFile: "/var/run/grafana-server.pid", - }, - &procstat.Specification{ - PidFile: "/var/run/influxdb/influxd.pid", - }, - } + pstat.PidFile = "/var/run/grafana-server.pid" pConfig := &PluginConfig{Name: "procstat"} + pConfig.Tags = make(map[string]string) assert.Equal(t, pstat, c.Plugins[3].Plugin, "Merged Testdata did not produce a correct procstat struct.") diff --git a/internal/config/testdata/subconfig/exec.conf b/internal/config/testdata/subconfig/exec.conf index 552441031..80aca00e8 100644 --- a/internal/config/testdata/subconfig/exec.conf +++ b/internal/config/testdata/subconfig/exec.conf @@ -1,6 +1,4 @@ [[plugins.exec]] - # specify commands via an array of tables - [[plugins.exec.commands]] # the command to run command = "/usr/bin/myothercollector --foo=bar" diff --git a/internal/config/testdata/subconfig/procstat.conf b/internal/config/testdata/subconfig/procstat.conf index 33f288d84..9f23e8d58 100644 --- a/internal/config/testdata/subconfig/procstat.conf +++ b/internal/config/testdata/subconfig/procstat.conf @@ -1,5 +1,2 @@ [[plugins.procstat]] - [[plugins.procstat.specifications]] pid_file = "/var/run/grafana-server.pid" - [[plugins.procstat.specifications]] - pid_file = "/var/run/influxdb/influxd.pid"