diff --git a/config_example.yaml b/config_example.yml similarity index 100% rename from config_example.yaml rename to config_example.yml diff --git a/main.go b/main.go index 884d1a8..1989d01 100644 --- a/main.go +++ b/main.go @@ -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 { diff --git a/models/config.go b/models/config.go index 0f35088..17c0e89 100644 --- a/models/config.go +++ b/models/config.go @@ -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) diff --git a/models/config_test.go b/models/config_test.go new file mode 100644 index 0000000..c78a4ab --- /dev/null +++ b/models/config_test.go @@ -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) +}