Fix config test
This commit is contained in:
parent
f5b24dfab2
commit
6f950c9376
|
@ -17,34 +17,25 @@ func TestReadConfig(t *testing.T) {
|
||||||
assert.True(config.Respondd.Enable)
|
assert.True(config.Respondd.Enable)
|
||||||
assert.Equal([]string{"br-ffhb"}, config.Respondd.Interfaces)
|
assert.Equal([]string{"br-ffhb"}, config.Respondd.Interfaces)
|
||||||
assert.Equal(time.Minute, config.Respondd.CollectInterval.Duration)
|
assert.Equal(time.Minute, config.Respondd.CollectInterval.Duration)
|
||||||
|
|
||||||
assert.Equal(time.Hour*24*7, config.Nodes.PruneAfter.Duration)
|
assert.Equal(time.Hour*24*7, config.Nodes.PruneAfter.Duration)
|
||||||
|
|
||||||
assert.Equal(time.Hour*24*7, config.Database.DeleteAfter.Duration)
|
assert.Equal(time.Hour*24*7, config.Database.DeleteAfter.Duration)
|
||||||
|
|
||||||
var meshviewer map[string]interface{}
|
// Test output plugins
|
||||||
var outputs []map[string]interface{}
|
assert.Len(config.Nodes.Output, 3)
|
||||||
outputs = config.Nodes.Output["meshviewer"].([]map[string]interface{})
|
outputs := config.Nodes.Output["meshviewer"].([]interface{})
|
||||||
assert.Len(outputs, 1, "more outputs are given")
|
assert.Len(outputs, 1)
|
||||||
meshviewer = outputs[0]
|
meshviewer := outputs[0]
|
||||||
assert.Equal(int64(2), meshviewer["version"])
|
|
||||||
assert.Equal("/var/www/html/meshviewer/data/nodes.json", meshviewer["nodes_path"])
|
|
||||||
|
|
||||||
var influxdb map[string]interface{}
|
assert.EqualValues(map[string]interface{}{
|
||||||
dbs := config.Database.Connection["influxdb"].([]map[string]interface{})
|
"version": int64(2),
|
||||||
assert.Len(dbs, 1, "more influxdb are given")
|
"enable": false,
|
||||||
influxdb = dbs[0]
|
"nodes_path": "/var/www/html/meshviewer/data/nodes.json",
|
||||||
assert.Equal(influxdb["database"], "ffhb")
|
"graph_path": "/var/www/html/meshviewer/data/graph.json",
|
||||||
|
}, meshviewer)
|
||||||
var graphitedb map[string]interface{}
|
|
||||||
dbs = config.Database.Connection["graphite"].([]map[string]interface{})
|
|
||||||
assert.Len(dbs, 1, "more graphitedb are given")
|
|
||||||
graphitedb = dbs[0]
|
|
||||||
assert.Equal(graphitedb["address"], "localhost:2003")
|
|
||||||
|
|
||||||
_, err = ReadConfigFile("testdata/config_invalid.toml")
|
_, err = ReadConfigFile("testdata/config_invalid.toml")
|
||||||
assert.Error(err, "not unmarshalable")
|
assert.Error(err, "not unmarshalable")
|
||||||
assert.Contains(err.Error(), "Near line ")
|
assert.Contains(err.Error(), "invalid TOML syntax")
|
||||||
|
|
||||||
_, err = ReadConfigFile("testdata/adsa.toml")
|
_, err = ReadConfigFile("testdata/adsa.toml")
|
||||||
assert.Error(err, "not found able")
|
assert.Error(err, "not found able")
|
||||||
|
|
Loading…
Reference in New Issue