chore(config): check error from load yaml config.
This commit is contained in:
@@ -29,7 +29,7 @@ func (suite *ConfigTestSuite) SetupTest() {
|
||||
if err != nil {
|
||||
panic("failed to load default config.yml")
|
||||
}
|
||||
suite.ConfGorush, err = LoadConf("config.yml")
|
||||
suite.ConfGorush, err = LoadConf("testdata/config.yml")
|
||||
if err != nil {
|
||||
panic("failed to load config.yml from file")
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func (suite *ConfigTestSuite) TestValidateConfDefault() {
|
||||
|
||||
// iOS
|
||||
assert.Equal(suite.T(), false, suite.ConfGorushDefault.Ios.Enabled)
|
||||
assert.Equal(suite.T(), "key.pem", suite.ConfGorushDefault.Ios.KeyPath)
|
||||
assert.Equal(suite.T(), "", suite.ConfGorushDefault.Ios.KeyPath)
|
||||
assert.Equal(suite.T(), "", suite.ConfGorushDefault.Ios.KeyBase64)
|
||||
assert.Equal(suite.T(), "pem", suite.ConfGorushDefault.Ios.KeyType)
|
||||
assert.Equal(suite.T(), "", suite.ConfGorushDefault.Ios.Password)
|
||||
@@ -191,7 +191,7 @@ func TestLoadConfigFromEnv(t *testing.T) {
|
||||
os.Setenv("GORUSH_IOS_KEY_ID", "ABC123DEFG")
|
||||
os.Setenv("GORUSH_IOS_TEAM_ID", "DEF123GHIJ")
|
||||
os.Setenv("GORUSH_API_HEALTH_URI", "/healthz")
|
||||
ConfGorush, err := LoadConf("config.yml")
|
||||
ConfGorush, err := LoadConf("testdata/config.yml")
|
||||
if err != nil {
|
||||
panic("failed to load config.yml from file")
|
||||
}
|
||||
@@ -202,3 +202,14 @@ func TestLoadConfigFromEnv(t *testing.T) {
|
||||
assert.Equal(t, "DEF123GHIJ", ConfGorush.Ios.TeamID)
|
||||
assert.Equal(t, "/healthz", ConfGorush.API.HealthURI)
|
||||
}
|
||||
|
||||
func TestLoadWrongYAMLConfig(t *testing.T) {
|
||||
_, err := LoadConf("testdata/wrong.yml")
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestLoadWrongDefaultYAMLConfig(t *testing.T) {
|
||||
defaultConf = []byte(`a`)
|
||||
_, err := LoadConf("")
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user