Skip to content

Commit

Permalink
SleepIfNeeded unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jaanus committed Aug 10, 2024
1 parent ced84f7 commit db4c537
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Targets/Canopy/Tests/ReplayingMockDatabaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,21 @@ final class ReplayingMockDatabaseTests: XCTestCase {
let result2 = try! await db.fetchRecords(with: []).get()
XCTAssertEqual(result2.notFoundRecordIDs[0].recordName, "notFound1")
}

func test_sleep_if_needed() async {
let db = ReplayingMockDatabase(
operationResults: [
.queryRecords(
.init(
result: .success([
.mock(.init(recordID: .init(recordName: "mockName"), recordType: "MockType"))
])
)
)
],
sleepBeforeEachOperation: 0.01
)
let result = try! await db.queryRecords(with: .init(recordType: "MockType", predicate: NSPredicate(value: true)), in: nil).get()
XCTAssertEqual(result.first!.recordID.recordName, "mockName")
}
}

0 comments on commit db4c537

Please # to comment.