Add test for reading the config.yml

This commit is contained in:
Julian Kornberger 2016-03-20 19:54:43 +01:00
parent 9352ef7f12
commit b252274253
4 changed files with 17 additions and 3 deletions

View File

@ -30,7 +30,7 @@ var (
func main() {
flag.StringVar(&configFile, "config", "config.yml", "path of configuration file (default:config.yaml)")
flag.Parse()
config = models.ConfigReadFile(configFile)
config = models.ReadConfigFile(configFile)
nodes = models.NewNodes(config)
if config.Influxdb.Enable {

View File

@ -40,8 +40,8 @@ type Config struct {
}
}
//ConfigReadFile reads a Config models by path to a yml file
func ConfigReadFile(path string) *Config {
// reads a config models by path to a yml file
func ReadConfigFile(path string) *Config {
config := &Config{}
file, _ := ioutil.ReadFile(path)
err := yaml.Unmarshal(file, &config)

14
models/config_test.go Normal file
View File

@ -0,0 +1,14 @@
package models
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestReadConfig(t *testing.T) {
assert := assert.New(t)
config := ReadConfigFile("../config_example.yml")
assert.NotNil(config)
}