Skip to content

Commit

Permalink
Don't wait for a timeout if too many documents exist
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoyne committed Nov 27, 2023
1 parent 08a7159 commit 73aad1e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Realm/ObjectServerTests/SwiftAsymmetricSyncServerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,16 @@ extension SwiftAsymmetricSyncTests {
let mongoClient = user.mongoClient("mongodb1")
let database = mongoClient.database(named: "test_data")
let collection = database.collection(withName: collection)
while collection.count(filter: [:]).await(self) != expectedCount && waitStart.timeIntervalSinceNow > -600.0 {
sleep(5)
while try await collection.count(filter: [:]) < expectedCount && waitStart.timeIntervalSinceNow > -600.0 {
try await Task.sleep(for: .seconds(5))
}

XCTAssertEqual(collection.count(filter: [:]).await(self), expectedCount)
}

@MainActor
func testCreateAsymmetricObject() async throws {
_ = try await setupCollection("SwiftObjectAsymmetric")
let realm = try await realm()

// Create Asymmetric Objects
Expand Down Expand Up @@ -273,6 +274,7 @@ extension SwiftAsymmetricSyncTests {

@MainActor
func testCreateHugeAsymmetricObject() async throws {
_ = try await setupCollection("HugeObjectAsymmetric")
let realm = try await realm()

// Create Asymmetric Objects
Expand Down
2 changes: 1 addition & 1 deletion Realm/ObjectServerTests/SwiftSyncTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ open class SwiftSyncTestCase: RLMSyncTestCase {

public func waitForCollectionCount(_ collection: MongoCollection, _ count: Int) {
let waitStart = Date()
while collection.count(filter: [:]).await(self) != count && waitStart.timeIntervalSinceNow > -600.0 {
while collection.count(filter: [:]).await(self) < count && waitStart.timeIntervalSinceNow > -600.0 {
sleep(1)
}
XCTAssertEqual(collection.count(filter: [:]).await(self), count)
Expand Down

0 comments on commit 73aad1e

Please sign in to comment.