chore(conf): add default value for max_concurrent_pushes (#646)
This commit is contained in:
@@ -277,10 +277,17 @@ type SectionGRPC struct {
|
||||
Port string `yaml:"port"`
|
||||
}
|
||||
|
||||
func setDefault() {
|
||||
viper.SetDefault("ios.max_concurrent_pushes", uint(100))
|
||||
}
|
||||
|
||||
// LoadConf load config from file and read in environment variables that match
|
||||
func LoadConf(confPath ...string) (*ConfYaml, error) {
|
||||
conf := &ConfYaml{}
|
||||
|
||||
// load default values
|
||||
setDefault()
|
||||
|
||||
viper.SetConfigType("yaml")
|
||||
viper.AutomaticEnv() // read in environment variables that match
|
||||
viper.SetEnvPrefix("gorush") // will be uppercased automatically
|
||||
|
||||
@@ -17,6 +17,15 @@ func TestMissingFile(t *testing.T) {
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestEmptyConfig(t *testing.T) {
|
||||
conf, err := LoadConf("testdata/empty.yml")
|
||||
if err != nil {
|
||||
panic("failed to load config.yml from file")
|
||||
}
|
||||
|
||||
assert.Equal(t, uint(100), conf.Ios.MaxConcurrentPushes)
|
||||
}
|
||||
|
||||
type ConfigTestSuite struct {
|
||||
suite.Suite
|
||||
ConfGorushDefault *ConfYaml
|
||||
|
||||
0
config/testdata/empty.yml
vendored
Normal file
0
config/testdata/empty.yml
vendored
Normal file
Reference in New Issue
Block a user