0.3.0 unit tests: internal

This commit is contained in:
Cameron Sparr 2016-01-07 10:23:38 -07:00
parent 0e398f5802
commit 4fdcb136bc
3 changed files with 8 additions and 19 deletions

View File

@ -39,6 +39,7 @@ func TestConfig_LoadSinglePlugin(t *testing.T) {
}, },
Interval: 5 * time.Second, Interval: 5 * time.Second,
} }
mConfig.Tags = make(map[string]string)
assert.Equal(t, memcached, c.Plugins[0].Plugin, assert.Equal(t, memcached, c.Plugins[0].Plugin,
"Testdata did not produce a correct memcached struct.") "Testdata did not produce a correct memcached struct.")
@ -81,19 +82,18 @@ func TestConfig_LoadDirectory(t *testing.T) {
}, },
Interval: 5 * time.Second, Interval: 5 * time.Second,
} }
mConfig.Tags = make(map[string]string)
assert.Equal(t, memcached, c.Plugins[0].Plugin, assert.Equal(t, memcached, c.Plugins[0].Plugin,
"Testdata did not produce a correct memcached struct.") "Testdata did not produce a correct memcached struct.")
assert.Equal(t, mConfig, c.Plugins[0].Config, assert.Equal(t, mConfig, c.Plugins[0].Config,
"Testdata did not produce correct memcached metadata.") "Testdata did not produce correct memcached metadata.")
ex := plugins.Plugins["exec"]().(*exec.Exec) ex := plugins.Plugins["exec"]().(*exec.Exec)
ex.Commands = []*exec.Command{ ex.Command = "/usr/bin/myothercollector --foo=bar"
&exec.Command{ ex.Name = "myothercollector"
Command: "/usr/bin/myothercollector --foo=bar",
Name: "myothercollector",
},
}
eConfig := &PluginConfig{Name: "exec"} eConfig := &PluginConfig{Name: "exec"}
eConfig.Tags = make(map[string]string)
assert.Equal(t, ex, c.Plugins[1].Plugin, assert.Equal(t, ex, c.Plugins[1].Plugin,
"Merged Testdata did not produce a correct exec struct.") "Merged Testdata did not produce a correct exec struct.")
assert.Equal(t, eConfig, c.Plugins[1].Config, 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.") "Testdata did not produce correct memcached metadata.")
pstat := plugins.Plugins["procstat"]().(*procstat.Procstat) pstat := plugins.Plugins["procstat"]().(*procstat.Procstat)
pstat.Specifications = []*procstat.Specification{ pstat.PidFile = "/var/run/grafana-server.pid"
&procstat.Specification{
PidFile: "/var/run/grafana-server.pid",
},
&procstat.Specification{
PidFile: "/var/run/influxdb/influxd.pid",
},
}
pConfig := &PluginConfig{Name: "procstat"} pConfig := &PluginConfig{Name: "procstat"}
pConfig.Tags = make(map[string]string)
assert.Equal(t, pstat, c.Plugins[3].Plugin, assert.Equal(t, pstat, c.Plugins[3].Plugin,
"Merged Testdata did not produce a correct procstat struct.") "Merged Testdata did not produce a correct procstat struct.")

View File

@ -1,6 +1,4 @@
[[plugins.exec]] [[plugins.exec]]
# specify commands via an array of tables
[[plugins.exec.commands]]
# the command to run # the command to run
command = "/usr/bin/myothercollector --foo=bar" command = "/usr/bin/myothercollector --foo=bar"

View File

@ -1,5 +1,2 @@
[[plugins.procstat]] [[plugins.procstat]]
[[plugins.procstat.specifications]]
pid_file = "/var/run/grafana-server.pid" pid_file = "/var/run/grafana-server.pid"
[[plugins.procstat.specifications]]
pid_file = "/var/run/influxdb/influxd.pid"