Fix push notification flaky test
This commit is contained in:
parent
79716227db
commit
665bc3743c
|
@ -173,7 +173,7 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotification() {
|
||||||
messageID, err := hex.DecodeString(messageIDString[2:])
|
messageID, err := hex.DecodeString(messageIDString[2:])
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
var info []*pushnotificationclient.PushNotificationInfo
|
infoMap := make(map[string]*pushnotificationclient.PushNotificationInfo)
|
||||||
err = tt.RetryWithBackOff(func() error {
|
err = tt.RetryWithBackOff(func() error {
|
||||||
_, err = server.RetrieveAll()
|
_, err = server.RetrieveAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -184,30 +184,29 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotification() {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err = alice.pushNotificationClient.GetPushNotificationInfo(&bob1.identity.PublicKey, bobInstallationIDs)
|
info, err := alice.pushNotificationClient.GetPushNotificationInfo(&bob1.identity.PublicKey, bobInstallationIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
for _, i := range info {
|
||||||
|
infoMap[i.AccessToken] = i
|
||||||
|
}
|
||||||
|
|
||||||
// Check we have replies for both bob1 and bob2
|
// Check we have replies for both bob1 and bob2
|
||||||
if len(info) != 2 {
|
if len(infoMap) != 2 {
|
||||||
return errors.New("info not fetched")
|
return errors.New("info not fetched")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
s.Require().NoError(err)
|
s.Require().Len(infoMap, 2)
|
||||||
|
|
||||||
// Check we have replies for both bob1 and bob2
|
// Check we have replies for both bob1 and bob2
|
||||||
var bob1Info, bob2Info *pushnotificationclient.PushNotificationInfo
|
var bob1Info, bob2Info *pushnotificationclient.PushNotificationInfo
|
||||||
|
|
||||||
if info[0].AccessToken == bob1Servers[0].AccessToken {
|
bob1Info = infoMap[bob1Servers[0].AccessToken]
|
||||||
bob1Info = info[0]
|
bob2Info = infoMap[bob2Servers[0].AccessToken]
|
||||||
bob2Info = info[1]
|
|
||||||
} else {
|
|
||||||
bob2Info = info[0]
|
|
||||||
bob1Info = info[1]
|
|
||||||
}
|
|
||||||
|
|
||||||
s.Require().NotNil(bob1Info)
|
s.Require().NotNil(bob1Info)
|
||||||
s.Require().Equal(bob1.installationID, bob1Info.InstallationID)
|
s.Require().Equal(bob1.installationID, bob1Info.InstallationID)
|
||||||
|
|
Loading…
Reference in New Issue