Fixing config tests and unexporting some functions

This commit is contained in:
Denis-Cosmin Nutiu 2017-11-23 21:23:55 +02:00
parent 6d96530227
commit b39f6c62ba
2 changed files with 7 additions and 8 deletions

View file

@ -12,8 +12,8 @@ import (
// ConfigPath will be used via cmd to set the configuration path for the config file.
var ConfigPath string
// LoadConfig tries to load the configuration file from the disk.
func LoadConfigFromFile() error {
// loadConfigFromFile tries to load the configuration file from the disk.
func loadConfigFromFile() error {
viper.SetConfigName("config")
viper.AddConfigPath(viper.GetString("ConfigPath"))
@ -24,8 +24,8 @@ func LoadConfigFromFile() error {
return err
}
// SetDefaultConfiguration will set the default configuration settings.
func SetDefaultConfiguration() {
// setDefaultConfiguration will set the default configuration settings.
func setDefaultConfiguration() {
viper.SetDefault("Address", "localhost")
viper.SetDefault("Port", "8080")
viper.SetDefault("ConfigPath", ConfigPath)
@ -38,8 +38,8 @@ func InitializedConfiguration() {
flag.StringVar(&ConfigPath, "ConfigPath", ".", "Set the location of the config file.")
flag.Parse()
SetDefaultConfiguration()
setDefaultConfiguration()
LoadConfigFromFile()
loadConfigFromFile()
BasePath = viper.GetString("AbsoluteServePath")
}

View file

@ -8,8 +8,7 @@ import (
func TestLoadConfigFromFile(t *testing.T) {
// SetDefaultConfiguration must be called BEFORE LoadConfigFromFile.
SetDefaultConfiguration()
LoadConfigFromFile()
InitializedConfiguration()
Address := viper.GetString("Address")
if Address == "" {