From e7898a50354487f27c8017733d5c2634173adb7d Mon Sep 17 00:00:00 2001 From: Miguel dos Reis Date: Thu, 12 Dec 2024 14:22:52 -0300 Subject: [PATCH] Fix tests --- docker-compose.yml | 2 +- e2e/apns_e2e_test.go | 1 - pusher/apns.go | 11 +++++++++-- pusher/gcm.go | 14 ++++++++++---- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e38a5d0..00f79c1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -88,7 +88,7 @@ services: retries: 10 kafka-ui: - image: docker.redpanda.com/vectorized/console:latest + image: docker.redpanda.com/redpandadata/console:latest ports: - 9000:8080 depends_on: diff --git a/e2e/apns_e2e_test.go b/e2e/apns_e2e_test.go index 87981d2..f07fe86 100644 --- a/e2e/apns_e2e_test.go +++ b/e2e/apns_e2e_test.go @@ -454,7 +454,6 @@ func (s *ApnsE2ETestSuite) TestConsumeMessagesBeforeExiting() { } func (s *ApnsE2ETestSuite) TestConsumeMessagesBeforeExitingWithRetries() { - app, p, mockApnsClient, statsdClientMock, responsesChannel := s.setupApnsPusher() ctx := context.Background() ctx, cancel := context.WithCancel(ctx) diff --git a/pusher/apns.go b/pusher/apns.go index 7ee3262..aedcb62 100644 --- a/pusher/apns.go +++ b/pusher/apns.go @@ -25,6 +25,7 @@ package pusher import ( "errors" "fmt" + "slices" "github.com/sirupsen/logrus" "github.com/spf13/viper" @@ -94,8 +95,14 @@ func (a *APNSPusher) configure(queue interfaces.APNSPushQueue, db interfaces.DB, } for _, a := range a.Config.GetApnsAppsArray() { - q.Topics = append(q.Topics, fmt.Sprintf("push-%s_apns-single", a)) - q.Topics = append(q.Topics, fmt.Sprintf("push-%s_apns-massive", a)) + singleTopic := fmt.Sprintf("push-%s_apns-single", a) + if !slices.Contains(q.Topics, singleTopic) { + q.Topics = append(q.Topics, singleTopic) + } + massiveTopic := fmt.Sprintf("push-%s_apns-massive", a) + if !slices.Contains(q.Topics, massiveTopic) { + q.Topics = append(q.Topics, massiveTopic) + } } a.MessageHandler = make(map[string]interfaces.MessageHandler) diff --git a/pusher/gcm.go b/pusher/gcm.go index 18cb169..52fad2c 100644 --- a/pusher/gcm.go +++ b/pusher/gcm.go @@ -25,14 +25,14 @@ package pusher import ( "context" "fmt" - "github.com/topfreegames/pusher/extensions/firebase/client" - "github.com/sirupsen/logrus" "github.com/spf13/viper" "github.com/topfreegames/pusher/config" "github.com/topfreegames/pusher/extensions" "github.com/topfreegames/pusher/extensions/firebase" + "github.com/topfreegames/pusher/extensions/firebase/client" "github.com/topfreegames/pusher/interfaces" + "slices" ) // GCMPusher struct for GCM pusher @@ -82,8 +82,14 @@ func NewGCMPusher( } g.Queue = q for _, a := range g.Config.GetGcmAppsArray() { - q.Topics = append(q.Topics, fmt.Sprintf("push-%s_gcm-single", a)) - q.Topics = append(q.Topics, fmt.Sprintf("push-%s_gcm-massive", a)) + singleTopic := fmt.Sprintf("push-%s_gcm-single", a) + if !slices.Contains(q.Topics, singleTopic) { + q.Topics = append(q.Topics, singleTopic) + } + massiveTopic := fmt.Sprintf("push-%s_gcm-massive", a) + if !slices.Contains(q.Topics, massiveTopic) { + q.Topics = append(q.Topics, massiveTopic) + } } err = g.createMessageHandlerForApps(ctx)