add max retry flag.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-10-23 16:22:49 +08:00
parent 731c35baa6
commit 411f413484
3 changed files with 12 additions and 2 deletions

View File

@ -44,6 +44,7 @@ type SectionAPI struct {
type SectionAndroid struct { type SectionAndroid struct {
Enabled bool `yaml:"enabled"` Enabled bool `yaml:"enabled"`
APIKey string `yaml:"apikey"` APIKey string `yaml:"apikey"`
MaxRetry int `yaml:"max_retry"`
} }
// SectionIos is sub section of config. // SectionIos is sub section of config.
@ -52,6 +53,7 @@ type SectionIos struct {
KeyPath string `yaml:"key_path"` KeyPath string `yaml:"key_path"`
Password string `yaml:"password"` Password string `yaml:"password"`
Production bool `yaml:"production"` Production bool `yaml:"production"`
MaxRetry int `yaml:"max_retry"`
} }
// SectionLog is sub section of config. // SectionLog is sub section of config.
@ -131,12 +133,14 @@ func BuildDefaultPushConf() ConfYaml {
// Android // Android
conf.Android.Enabled = false conf.Android.Enabled = false
conf.Android.APIKey = "" conf.Android.APIKey = ""
conf.Android.MaxRetry = 1
// iOS // iOS
conf.Ios.Enabled = false conf.Ios.Enabled = false
conf.Ios.KeyPath = "key.pem" conf.Ios.KeyPath = "key.pem"
conf.Ios.Password = "" conf.Ios.Password = ""
conf.Ios.Production = false conf.Ios.Production = false
conf.Ios.MaxRetry = 1
// log // log
conf.Log.Format = "string" conf.Log.Format = "string"

View File

@ -23,12 +23,14 @@ api:
android: android:
enabled: true enabled: true
apikey: "YOUR_API_KEY" apikey: "YOUR_API_KEY"
max_retry: 1
ios: ios:
enabled: false enabled: false
key_path: "key.pem" key_path: "key.pem"
password: "" password: ""
production: false production: false
max_retry: 1
log: log:
format: "string" # string or json format: "string" # string or json

View File

@ -78,12 +78,14 @@ func (suite *ConfigTestSuite) TestValidateConfDefault() {
// Android // Android
assert.Equal(suite.T(), false, suite.ConfGorushDefault.Android.Enabled) assert.Equal(suite.T(), false, suite.ConfGorushDefault.Android.Enabled)
assert.Equal(suite.T(), "", suite.ConfGorushDefault.Android.APIKey) assert.Equal(suite.T(), "", suite.ConfGorushDefault.Android.APIKey)
assert.Equal(suite.T(), 1, suite.ConfGorushDefault.Android.MaxRetry)
// iOS // iOS
assert.Equal(suite.T(), false, suite.ConfGorushDefault.Ios.Enabled) assert.Equal(suite.T(), false, suite.ConfGorushDefault.Ios.Enabled)
assert.Equal(suite.T(), "key.pem", suite.ConfGorushDefault.Ios.KeyPath) assert.Equal(suite.T(), "key.pem", suite.ConfGorushDefault.Ios.KeyPath)
assert.Equal(suite.T(), "", suite.ConfGorushDefault.Ios.Password) assert.Equal(suite.T(), "", suite.ConfGorushDefault.Ios.Password)
assert.Equal(suite.T(), false, suite.ConfGorushDefault.Ios.Production) assert.Equal(suite.T(), false, suite.ConfGorushDefault.Ios.Production)
assert.Equal(suite.T(), 1, suite.ConfGorushDefault.Ios.MaxRetry)
// log // log
assert.Equal(suite.T(), "string", suite.ConfGorushDefault.Log.Format) assert.Equal(suite.T(), "string", suite.ConfGorushDefault.Log.Format)
@ -131,12 +133,14 @@ func (suite *ConfigTestSuite) TestValidateConf() {
// Android // Android
assert.Equal(suite.T(), true, suite.ConfGorush.Android.Enabled) assert.Equal(suite.T(), true, suite.ConfGorush.Android.Enabled)
assert.Equal(suite.T(), "YOUR_API_KEY", suite.ConfGorush.Android.APIKey) assert.Equal(suite.T(), "YOUR_API_KEY", suite.ConfGorush.Android.APIKey)
assert.Equal(suite.T(), 1, suite.ConfGorush.Android.MaxRetry)
// iOS // iOS
assert.Equal(suite.T(), false, suite.ConfGorush.Ios.Enabled) assert.Equal(suite.T(), false, suite.ConfGorush.Ios.Enabled)
assert.Equal(suite.T(), "key.pem", suite.ConfGorush.Ios.KeyPath) assert.Equal(suite.T(), "key.pem", suite.ConfGorush.Ios.KeyPath)
assert.Equal(suite.T(), "", suite.ConfGorush.Ios.Password) assert.Equal(suite.T(), "", suite.ConfGorush.Ios.Password)
assert.Equal(suite.T(), false, suite.ConfGorush.Ios.Production) assert.Equal(suite.T(), false, suite.ConfGorush.Ios.Production)
assert.Equal(suite.T(), 1, suite.ConfGorush.Ios.MaxRetry)
// log // log
assert.Equal(suite.T(), "string", suite.ConfGorush.Log.Format) assert.Equal(suite.T(), "string", suite.ConfGorush.Log.Format)