Skip to content

Commit

Permalink
executor_test: make expectations order-independent
Browse files Browse the repository at this point in the history
The previous version was causing flakyness in tests since it assumed a specific
order for the devices, which is not guaranteed. The new version removes that
assumption. The presence of each and every target device is verified by the
`send_sync` mechanism anyway.

Signed-off-by: Riccardo Binetti <[email protected]>
  • Loading branch information
rbino committed Jul 8, 2024
1 parent db47cc7 commit 4149660
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,10 @@ defmodule Edgehog.UpdateCampaigns.PushRollout.ExecutorTest do
base_image_url = update_campaign.base_image.url
target_device_ids = Enum.map(update_campaign.update_targets, & &1.device.device_id)

# Set an expectation for each target on the OTARequest mock and send back a message
# to wait for all devices
Enum.each(target_device_ids, fn device_id ->
expect(OTARequestV1Mock, :update, fn _client, ^device_id, _uuid, ^base_image_url ->
send_sync(parent, {ref, device_id})
:ok
end)
# Expect target_count update calls and send back a message for each device
expect(OTARequestV1Mock, :update, target_count, fn _client, device_id, _uuid, ^base_image_url ->
send_sync(parent, {ref, device_id})
:ok
end)

pid = start_executor!(update_campaign)
Expand Down

0 comments on commit 4149660

Please sign in to comment.