Fix data race with push notification in test (#27682)

Fix for
https://github.com/fleetdm/fleet/actions/runs/14098566529/job/39490440108
This commit is contained in:
Martin Angers 2025-03-31 10:21:25 -04:00 committed by GitHub
parent 8fa88fdec0
commit 888e4a6a7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15311,14 +15311,22 @@ func (s *integrationMDMTestSuite) TestRecreateDeletedIPhoneBYOD() {
require.Len(t, listHostsRes.Hosts, 0)
// run the reviver cron job, will send a push notification to the deleted host
oriPushFunc := s.pushProvider.PushFunc
t.Cleanup(func() { s.pushProvider.PushFunc = oriPushFunc })
var recordedPushes []*mdm.Push
var pushMutex sync.Mutex
s.pushProvider.PushFunc = func(ctx context.Context, pushes []*mdm.Push) (map[string]*push.Response, error) {
pushMutex.Lock()
recordedPushes = pushes
pushMutex.Unlock()
return mockSuccessfulPush(ctx, pushes)
}
err := apple_mdm.IOSiPadOSRevive(context.Background(), s.ds, s.mdmCommander, s.logger)
require.NoError(t, err)
pushMutex.Lock()
require.Len(t, recordedPushes, 1)
pushMutex.Unlock()
// do an MDM sync (as the host would when triggered by the notification),
// will re-create the host and move it to its enrollment team