Only initial MaxConcurrentIOSPushes once. (#591)
This commit is contained in:
@@ -266,6 +266,7 @@ func handleNotification(ctx context.Context, cfg config.ConfYaml, req gorush.Req
|
||||
continue
|
||||
}
|
||||
}
|
||||
notification.Cfg = cfg
|
||||
newNotification = append(newNotification, notification)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/appleboy/gorush/gorush"
|
||||
"github.com/appleboy/gorush/logx"
|
||||
"github.com/appleboy/gorush/queue"
|
||||
"github.com/appleboy/gorush/queue/simple"
|
||||
"github.com/appleboy/gorush/status"
|
||||
|
||||
"github.com/appleboy/gofight/v2"
|
||||
@@ -27,6 +28,7 @@ import (
|
||||
var (
|
||||
goVersion = runtime.Version()
|
||||
q *queue.Queue
|
||||
w queue.Worker
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -44,9 +46,14 @@ func TestMain(m *testing.M) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
q = queue.NewQueue(cfg)
|
||||
w = simple.NewWorker(int(cfg.Core.QueueNum))
|
||||
q = queue.NewQueue(w)
|
||||
q.Start()
|
||||
defer q.Stop()
|
||||
defer func() {
|
||||
q.Stop()
|
||||
q.Wait()
|
||||
}()
|
||||
|
||||
m.Run()
|
||||
}
|
||||
|
||||
@@ -310,7 +317,7 @@ func TestMutableContent(t *testing.T) {
|
||||
{
|
||||
"tokens": []string{"aaaaa", "bbbbb"},
|
||||
"platform": core.PlatFormAndroid,
|
||||
"message": "Welcome",
|
||||
"message": "Welcome From API",
|
||||
"mutable_content": 1,
|
||||
"topic": "test",
|
||||
"badge": 1,
|
||||
@@ -341,12 +348,12 @@ func TestOutOfRangeMaxNotifications(t *testing.T) {
|
||||
{
|
||||
"tokens": []string{"aaaaa", "bbbbb"},
|
||||
"platform": core.PlatFormAndroid,
|
||||
"message": "Welcome",
|
||||
"message": "Welcome API From Android",
|
||||
},
|
||||
{
|
||||
"tokens": []string{"aaaaa", "bbbbb"},
|
||||
"platform": core.PlatFormAndroid,
|
||||
"message": "Welcome",
|
||||
"message": "Welcome API From Android",
|
||||
},
|
||||
},
|
||||
}).
|
||||
@@ -372,7 +379,7 @@ func TestSuccessPushHandler(t *testing.T) {
|
||||
{
|
||||
"tokens": []string{androidToken, "bbbbb"},
|
||||
"platform": core.PlatFormAndroid,
|
||||
"message": "Welcome",
|
||||
"message": "Welcome Android",
|
||||
},
|
||||
},
|
||||
}).
|
||||
@@ -462,7 +469,6 @@ func TestSenMultipleNotifications(t *testing.T) {
|
||||
|
||||
cfg.Android.Enabled = true
|
||||
cfg.Android.APIKey = os.Getenv("ANDROID_API_KEY")
|
||||
q.Config(cfg)
|
||||
|
||||
androidToken := os.Getenv("ANDROID_TEST_TOKEN")
|
||||
|
||||
@@ -472,13 +478,13 @@ func TestSenMultipleNotifications(t *testing.T) {
|
||||
{
|
||||
Tokens: []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
|
||||
Platform: core.PlatFormIos,
|
||||
Message: "Welcome",
|
||||
Message: "Welcome iOS",
|
||||
},
|
||||
// android
|
||||
{
|
||||
Tokens: []string{androidToken, "bbbbb"},
|
||||
Platform: core.PlatFormAndroid,
|
||||
Message: "Welcome",
|
||||
Message: "Welcome Android",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -499,7 +505,6 @@ func TestDisabledAndroidNotifications(t *testing.T) {
|
||||
|
||||
cfg.Android.Enabled = false
|
||||
cfg.Android.APIKey = os.Getenv("ANDROID_API_KEY")
|
||||
q.Config(cfg)
|
||||
|
||||
androidToken := os.Getenv("ANDROID_TEST_TOKEN")
|
||||
|
||||
@@ -507,15 +512,15 @@ func TestDisabledAndroidNotifications(t *testing.T) {
|
||||
Notifications: []gorush.PushNotification{
|
||||
// ios
|
||||
{
|
||||
Tokens: []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
|
||||
Tokens: []string{"11aa01229f15f0f0c5209d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
|
||||
Platform: core.PlatFormIos,
|
||||
Message: "Welcome",
|
||||
Message: "Welcome iOS",
|
||||
},
|
||||
// android
|
||||
{
|
||||
Tokens: []string{androidToken, "bbbbb"},
|
||||
Platform: core.PlatFormAndroid,
|
||||
Message: "Welcome",
|
||||
Message: "Welcome Android",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -539,7 +544,6 @@ func TestSyncModeForNotifications(t *testing.T) {
|
||||
|
||||
// enable sync mode
|
||||
cfg.Core.Sync = true
|
||||
q.Config(cfg)
|
||||
|
||||
androidToken := os.Getenv("ANDROID_TEST_TOKEN")
|
||||
|
||||
@@ -547,15 +551,17 @@ func TestSyncModeForNotifications(t *testing.T) {
|
||||
Notifications: []gorush.PushNotification{
|
||||
// ios
|
||||
{
|
||||
Tokens: []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
|
||||
Tokens: []string{
|
||||
"11aa01229f15f0f0c12029d8c111d1ae1f2365f14cebc4af26cd6d76b7919ef7",
|
||||
},
|
||||
Platform: core.PlatFormIos,
|
||||
Message: "Welcome",
|
||||
Message: "Welcome iOS Sync",
|
||||
},
|
||||
// android
|
||||
{
|
||||
Tokens: []string{androidToken, "bbbbb"},
|
||||
Platform: core.PlatFormAndroid,
|
||||
Message: "Welcome",
|
||||
Message: "Welcome Android Sync",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -575,7 +581,6 @@ func TestSyncModeForTopicNotification(t *testing.T) {
|
||||
|
||||
// enable sync mode
|
||||
cfg.Core.Sync = true
|
||||
q.Config(cfg)
|
||||
|
||||
req := gorush.RequestPush{
|
||||
Notifications: []gorush.PushNotification{
|
||||
@@ -597,6 +602,7 @@ func TestSyncModeForTopicNotification(t *testing.T) {
|
||||
// android
|
||||
{
|
||||
// success
|
||||
Cfg: cfg,
|
||||
Condition: "'dogs' in topics || 'cats' in topics",
|
||||
Platform: core.PlatFormAndroid,
|
||||
Message: "This is a Firebase Cloud Messaging Topic Message!",
|
||||
@@ -619,7 +625,6 @@ func TestSyncModeForDeviceGroupNotification(t *testing.T) {
|
||||
|
||||
// enable sync mode
|
||||
cfg.Core.Sync = true
|
||||
q.Config(cfg)
|
||||
|
||||
req := gorush.RequestPush{
|
||||
Notifications: []gorush.PushNotification{
|
||||
@@ -648,7 +653,6 @@ func TestDisabledIosNotifications(t *testing.T) {
|
||||
|
||||
cfg.Android.Enabled = true
|
||||
cfg.Android.APIKey = os.Getenv("ANDROID_API_KEY")
|
||||
q.Config(cfg)
|
||||
|
||||
androidToken := os.Getenv("ANDROID_TEST_TOKEN")
|
||||
|
||||
@@ -656,15 +660,15 @@ func TestDisabledIosNotifications(t *testing.T) {
|
||||
Notifications: []gorush.PushNotification{
|
||||
// ios
|
||||
{
|
||||
Tokens: []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
|
||||
Tokens: []string{"11aa01229f15f0f0c52021d8cf3cd0ae1f2365fe4cebc4af26cd6d76b7919ef7"},
|
||||
Platform: core.PlatFormIos,
|
||||
Message: "Welcome",
|
||||
Message: "Welcome iOS platform",
|
||||
},
|
||||
// android
|
||||
{
|
||||
Tokens: []string{androidToken, androidToken + "_"},
|
||||
Platform: core.PlatFormAndroid,
|
||||
Message: "Welcome",
|
||||
Message: "Welcome Android platform",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user