ably / ably-asset-tracking-swift

iOS client SDKs for the Ably Asset Tracking service.
Apache License 2.0
9 stars 6 forks source link

Fix situations where `changeRoutingProfile` doesn’t call its callback #474

Closed lawrence-forooghian closed 1 year ago

lawrence-forooghian commented 1 year ago

In situations where there either was no active trackable, or the active trackable had no destination, the completion handler of changeRoutingProfile(profile:completion:) would not be called.

This fixes that by making sure that we always call the callback. In the case where there is no active trackable with a destination, we simply update the publisher’s routing profile and call the callback immediately. This is consistent with the behaviour on Android, as described by Kacper.

Our existing tests for this method didn’t catch this because they weren’t actually waiting for the callback, and so none of their assertions were executed. So I’ve fixed those tests and added some more.

The fact that the tests’ assertions weren’t being called also hid another issue with DefaultPublisher – namely, that it was ignoring the routing profile that was passed to changeRoutingProfile. I’ve fixed this, too.

Closes #420.