Fixing config tests and unexporting some functions
This commit is contained in:
parent
6d96530227
commit
b39f6c62ba
2 changed files with 7 additions and 8 deletions
|
@ -12,8 +12,8 @@ import (
|
||||||
// ConfigPath will be used via cmd to set the configuration path for the config file.
|
// ConfigPath will be used via cmd to set the configuration path for the config file.
|
||||||
var ConfigPath string
|
var ConfigPath string
|
||||||
|
|
||||||
// LoadConfig tries to load the configuration file from the disk.
|
// loadConfigFromFile tries to load the configuration file from the disk.
|
||||||
func LoadConfigFromFile() error {
|
func loadConfigFromFile() error {
|
||||||
viper.SetConfigName("config")
|
viper.SetConfigName("config")
|
||||||
viper.AddConfigPath(viper.GetString("ConfigPath"))
|
viper.AddConfigPath(viper.GetString("ConfigPath"))
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ func LoadConfigFromFile() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDefaultConfiguration will set the default configuration settings.
|
// setDefaultConfiguration will set the default configuration settings.
|
||||||
func SetDefaultConfiguration() {
|
func setDefaultConfiguration() {
|
||||||
viper.SetDefault("Address", "localhost")
|
viper.SetDefault("Address", "localhost")
|
||||||
viper.SetDefault("Port", "8080")
|
viper.SetDefault("Port", "8080")
|
||||||
viper.SetDefault("ConfigPath", ConfigPath)
|
viper.SetDefault("ConfigPath", ConfigPath)
|
||||||
|
@ -38,8 +38,8 @@ func InitializedConfiguration() {
|
||||||
flag.StringVar(&ConfigPath, "ConfigPath", ".", "Set the location of the config file.")
|
flag.StringVar(&ConfigPath, "ConfigPath", ".", "Set the location of the config file.")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
SetDefaultConfiguration()
|
setDefaultConfiguration()
|
||||||
|
|
||||||
LoadConfigFromFile()
|
loadConfigFromFile()
|
||||||
BasePath = viper.GetString("AbsoluteServePath")
|
BasePath = viper.GetString("AbsoluteServePath")
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,7 @@ import (
|
||||||
|
|
||||||
func TestLoadConfigFromFile(t *testing.T) {
|
func TestLoadConfigFromFile(t *testing.T) {
|
||||||
// SetDefaultConfiguration must be called BEFORE LoadConfigFromFile.
|
// SetDefaultConfiguration must be called BEFORE LoadConfigFromFile.
|
||||||
SetDefaultConfiguration()
|
InitializedConfiguration()
|
||||||
LoadConfigFromFile()
|
|
||||||
|
|
||||||
Address := viper.GetString("Address")
|
Address := viper.GetString("Address")
|
||||||
if Address == "" {
|
if Address == "" {
|
||||||
|
|
Loading…
Reference in a new issue