2017-11-26 20:06:45 +00:00
|
|
|
package config
|
2017-11-16 09:19:01 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestLoadConfigFromFile(t *testing.T) {
|
|
|
|
// SetDefaultConfiguration must be called BEFORE LoadConfigFromFile.
|
2018-10-23 06:12:48 +00:00
|
|
|
InitializeConfiguration("docker-config", "./")
|
2017-11-16 09:19:01 +00:00
|
|
|
|
2017-11-24 20:37:09 +00:00
|
|
|
Address := viper.GetString("address")
|
2017-11-16 09:19:01 +00:00
|
|
|
if Address == "" {
|
|
|
|
t.Error("TestLoadConfigFromFile: Can't get Address!")
|
|
|
|
}
|
|
|
|
|
2017-11-26 21:03:15 +00:00
|
|
|
Port := viper.GetInt("port")
|
|
|
|
if Port == 0 {
|
2017-11-16 09:19:01 +00:00
|
|
|
t.Error("TestLoadConfigFromFile: Can't get Port!")
|
|
|
|
}
|
|
|
|
|
2017-11-24 20:37:09 +00:00
|
|
|
ConfigPath := viper.GetString("configPath")
|
2017-11-16 09:19:01 +00:00
|
|
|
if ConfigPath == "" {
|
|
|
|
t.Error("TestLoadConfigFromFile: Can't get ConfigPath!")
|
|
|
|
}
|
|
|
|
|
2017-11-24 20:37:09 +00:00
|
|
|
DirDepth := viper.GetInt("maxDirDepth")
|
2017-11-16 09:19:01 +00:00
|
|
|
if DirDepth == 0 {
|
|
|
|
t.Error("TestLoadConfigFromFile: Can't get DirDepth!")
|
|
|
|
}
|
|
|
|
|
2017-11-24 20:37:09 +00:00
|
|
|
BasePath := viper.GetString("absoluteServePath")
|
2017-11-16 09:19:01 +00:00
|
|
|
if BasePath == "" {
|
|
|
|
t.Error("TestLoadConfigFromFile: Can't get AbsoluteServePath!")
|
|
|
|
}
|
|
|
|
}
|