chore(conf): add default value for max_concurrent_pushes (#646)
This commit is contained in:
parent
20e6566183
commit
4c1c87aecc
|
@ -277,10 +277,17 @@ type SectionGRPC struct {
|
||||||
Port string `yaml:"port"`
|
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
|
// LoadConf load config from file and read in environment variables that match
|
||||||
func LoadConf(confPath ...string) (*ConfYaml, error) {
|
func LoadConf(confPath ...string) (*ConfYaml, error) {
|
||||||
conf := &ConfYaml{}
|
conf := &ConfYaml{}
|
||||||
|
|
||||||
|
// load default values
|
||||||
|
setDefault()
|
||||||
|
|
||||||
viper.SetConfigType("yaml")
|
viper.SetConfigType("yaml")
|
||||||
viper.AutomaticEnv() // read in environment variables that match
|
viper.AutomaticEnv() // read in environment variables that match
|
||||||
viper.SetEnvPrefix("gorush") // will be uppercased automatically
|
viper.SetEnvPrefix("gorush") // will be uppercased automatically
|
||||||
|
|
|
@ -17,6 +17,15 @@ func TestMissingFile(t *testing.T) {
|
||||||
assert.NotNil(t, err)
|
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 {
|
type ConfigTestSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
ConfGorushDefault *ConfYaml
|
ConfGorushDefault *ConfYaml
|
||||||
|
|
Loading…
Reference in New Issue