Support global ENV setting. (#293)

* Support global ENV setting.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* add viper package

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* fix typo

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* fix testing.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* fix testing.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2017-10-22 22:06:30 -05:00
committed by GitHub
parent e2d4d9db18
commit f3480d2dd8
165 changed files with 36925 additions and 157 deletions

View File

@@ -36,7 +36,7 @@ func TestSetLogOut(t *testing.T) {
}
func TestInitDefaultLog(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
// no errors on default config
assert.Nil(t, InitLog())
@@ -47,7 +47,7 @@ func TestInitDefaultLog(t *testing.T) {
}
func TestAccessLevel(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Log.AccessLevel = "invalid"
@@ -55,7 +55,7 @@ func TestAccessLevel(t *testing.T) {
}
func TestErrorLevel(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Log.ErrorLevel = "invalid"
@@ -63,7 +63,7 @@ func TestErrorLevel(t *testing.T) {
}
func TestAccessLogPath(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Log.AccessLog = "logs/access.log"
@@ -71,7 +71,7 @@ func TestAccessLogPath(t *testing.T) {
}
func TestErrorLogPath(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Log.ErrorLog = "logs/error.log"

View File

@@ -14,7 +14,8 @@ import (
)
func TestDisabledAndroidIosConf(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Android.Enabled = false
err := CheckPushConf()
@@ -23,7 +24,7 @@ func TestDisabledAndroidIosConf(t *testing.T) {
}
func TestMissingIOSCertificate(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Ios.Enabled = true
PushConf.Ios.KeyPath = ""
@@ -345,7 +346,7 @@ func TestIOSAlertNotificationStructure(t *testing.T) {
}
func TestDisabledIosNotifications(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Ios.Enabled = false
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
@@ -380,7 +381,7 @@ func TestDisabledIosNotifications(t *testing.T) {
}
func TestWrongIosCertificateExt(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Ios.Enabled = true
PushConf.Ios.KeyPath = "test"
@@ -391,7 +392,7 @@ func TestWrongIosCertificateExt(t *testing.T) {
}
func TestAPNSClientDevHost(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Ios.Enabled = true
PushConf.Ios.KeyPath = "../certificate/certificate-valid.p12"
@@ -401,7 +402,7 @@ func TestAPNSClientDevHost(t *testing.T) {
}
func TestAPNSClientProdHost(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Ios.Enabled = true
PushConf.Ios.Production = true
@@ -412,7 +413,7 @@ func TestAPNSClientProdHost(t *testing.T) {
}
func TestPushToIOS(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Ios.Enabled = true
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"

View File

@@ -11,7 +11,7 @@ import (
)
func init() {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
if err := InitLog(); err != nil {
log.Fatal(err)
}
@@ -24,7 +24,7 @@ func init() {
}
func TestMissingAndroidAPIKey(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Android.Enabled = true
PushConf.Android.APIKey = ""
@@ -43,7 +43,7 @@ func TestMissingKeyForInitFCMClient(t *testing.T) {
}
func TestPushToAndroidWrongToken(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Android.Enabled = true
PushConf.Android.APIKey = os.Getenv("ANDROID_API_KEY")
@@ -60,7 +60,7 @@ func TestPushToAndroidWrongToken(t *testing.T) {
}
func TestPushToAndroidRightTokenForJSONLog(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Android.Enabled = true
PushConf.Android.APIKey = os.Getenv("ANDROID_API_KEY")
@@ -80,7 +80,7 @@ func TestPushToAndroidRightTokenForJSONLog(t *testing.T) {
}
func TestPushToAndroidRightTokenForStringLog(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Android.Enabled = true
PushConf.Android.APIKey = os.Getenv("ANDROID_API_KEY")
@@ -98,7 +98,7 @@ func TestPushToAndroidRightTokenForStringLog(t *testing.T) {
}
func TestOverwriteAndroidAPIKey(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Android.Enabled = true
PushConf.Android.APIKey = os.Getenv("ANDROID_API_KEY")
@@ -177,7 +177,7 @@ func TestFCMMessage(t *testing.T) {
}
func TestCheckAndroidMessage(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Android.Enabled = true
PushConf.Android.APIKey = os.Getenv("ANDROID_API_KEY")

View File

@@ -9,7 +9,7 @@ import (
)
func TestCorrectConf(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Android.Enabled = true
PushConf.Android.APIKey = "xxxxx"
@@ -23,7 +23,7 @@ func TestCorrectConf(t *testing.T) {
}
func TestSenMultipleNotifications(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
InitWorkers(int64(2), 2)
@@ -60,7 +60,7 @@ func TestSenMultipleNotifications(t *testing.T) {
}
func TestDisabledAndroidNotifications(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Ios.Enabled = true
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
@@ -95,7 +95,7 @@ func TestDisabledAndroidNotifications(t *testing.T) {
}
func TestSyncModeForNotifications(t *testing.T) {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Ios.Enabled = true
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"

View File

@@ -17,7 +17,7 @@ import (
var goVersion = runtime.Version()
func initTest() {
PushConf = config.BuildDefaultPushConf()
PushConf, _ = config.LoadConf("")
PushConf.Core.Mode = "test"
}