Skip to content

Commit

Permalink
test: fix TestReadFromEnvironmentWithSpecifiedEnvSuffixName()
Browse files Browse the repository at this point in the history
  • Loading branch information
masu-mi committed Dec 13, 2021
1 parent f476821 commit bd12083
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions configor_test.go
Expand Up @@ -417,18 +417,15 @@ func TestOverwritetestConfigurationWithEnvironmentWithDefaultPrefix(t *testing.T
os.Setenv("CONFIGOR_APPNAME", "config2")
os.Setenv("CONFIGOR_HOSTS", "- http://example.org\n- http://jinzhu.me")
os.Setenv("CONFIGOR_DB_NAME", "db_name")
os.Setenv("CONFIGOR_META_INFO", "env_meta_info")
defer os.Setenv("CONFIGOR_APPNAME", "")
defer os.Setenv("CONFIGOR_HOSTS", "")
defer os.Setenv("CONFIGOR_DB_NAME", "")
defer os.Setenv("CONFIGOR_META_INFO", "")
Load(&result, file.Name())

var defaultConfig = generateDefaultConfig()
defaultConfig.APPName = "config2"
defaultConfig.Hosts = []string{"http://example.org", "http://jinzhu.me"}
defaultConfig.DB.Name = "db_name"
defaultConfig.MetaInfo = "env_meta_info"
if !reflect.DeepEqual(result, defaultConfig) {
t.Errorf("result should equal to original configuration")
}
Expand Down Expand Up @@ -575,12 +572,12 @@ func TestReadFromEnvironmentWithSpecifiedEnvSuffixName(t *testing.T) {
defer os.Remove(file.Name())
file.Write(bytes)
var result testConfig
os.Setenv("CONFIGOR_DB_NAME", "db_name_from_env")
defer os.Setenv("CONFIGOR_DB_NAME", "")
os.Setenv("CONFIGOR_META_INFO", "env_meta_info")
defer os.Setenv("CONFIGOR_META_INFO", "")
Load(&result, file.Name())

var defaultConfig = generateDefaultConfig()
defaultConfig.DB.Name = "db_name_from_env"
defaultConfig.MetaInfo = "env_meta_info"
if !reflect.DeepEqual(result, defaultConfig) {
t.Errorf("result should equal to original configuration")
}
Expand Down

0 comments on commit bd12083

Please sign in to comment.