Skip to content

Commit

Permalink
Test for API errors in our concurrent test
Browse files Browse the repository at this point in the history
  • Loading branch information
gazreese committed Feb 27, 2024
1 parent 08fa2ce commit 3d542db
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion FlagsmithClient/Tests/APIManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,25 @@ final class APIManagerTests: FlagsmithClientTestCase {

var expectations:[XCTestExpectation] = [];
let iterations = 1000
var error: FlagsmithError?

for concurrentIteration in 1...iterations {
let expectation = XCTestExpectation(description: "Multiple threads can access the APIManager \(concurrentIteration)")
expectations.append(expectation)
concurrentQueue.async {
self.apiManager.request(.getFlags) { (result: Result<Void, Error>) in
// We're not fussed at this point what the result is
if case let .failure(e) = result {
error = e as? FlagsmithError
}
expectation.fulfill()
}
}
}

wait(for: expectations, timeout: 5)
// Ensure that we didn't have any errors during the process
XCTAssertTrue(error == nil)

print("Finished!")
}
}

0 comments on commit 3d542db

Please sign in to comment.