Skip to content

Commit

Permalink
presenceMembers is updated with a delay, so we poll every second un…
Browse files Browse the repository at this point in the history
…til it's fulfilled by the realtime.
  • Loading branch information
maratal committed Feb 19, 2024
1 parent 9d1163f commit 5f7ab74
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Test/Tests/RestClientChannelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1635,13 +1635,28 @@ class RestClientChannelTests: XCTestCase {
done()
}
}
waitUntil(timeout: testTimeout) { done in

func checkMetrics(completion: @escaping (ARTChannelDetails) -> ()) {
restChannel.status { details, error in
XCTAssertNil(error)
guard let details = details else {
fail("Channel details are empty"); done()
fail("Channel details are empty");
return
}
if details.status.occupancy.metrics.presenceMembers == 1 {
completion(details)
}
else {
// `presenceMembers` is updated with a delay, so we poll every second until it's fulfilled by the realtime
delay(1.0) {
checkMetrics(completion: completion)
}
}
}
}

waitUntil(timeout: testTimeout) { done in
checkMetrics { details in
XCTAssertEqual(details.status.occupancy.metrics.connections, 1) // CHM2a
XCTAssertEqual(details.status.occupancy.metrics.publishers, 1) // CHM2e
XCTAssertEqual(details.status.occupancy.metrics.subscribers, 1) // CHM2f
Expand Down

0 comments on commit 5f7ab74

Please sign in to comment.