diff --git a/Tests/ConfidenceProviderTests/FlagApplierWithRetriesTest.swift b/Tests/ConfidenceProviderTests/FlagApplierWithRetriesTest.swift index 820da2da..7f2fb531 100644 --- a/Tests/ConfidenceProviderTests/FlagApplierWithRetriesTest.swift +++ b/Tests/ConfidenceProviderTests/FlagApplierWithRetriesTest.swift @@ -96,7 +96,7 @@ class FlagApplierWithRetriesTest: XCTestCase { await applier.apply(flagName: "flag2", resolveToken: "token1") await applier.apply(flagName: "flag3", resolveToken: "token1") - await waitForExpectations(timeout: 1.0) + await fulfillment(of: [networkExpectation], timeout: 1.0) // Then cache data is not stored on to the disk // But stored in the local cache as sent @@ -149,8 +149,7 @@ class FlagApplierWithRetriesTest: XCTestCase { metadata: metadata ) - await waitForExpectations(timeout: 5.0) - + await fulfillment(of: [expectation, storageExpectation], timeout: 1.0) // Then http client sends 5 apply flag batch request, containing 20 records each let request = try XCTUnwrap(httpClient.data?.first as? ApplyFlagsRequest) XCTAssertEqual(httpClient.postCallCounter, 5) @@ -180,7 +179,7 @@ class FlagApplierWithRetriesTest: XCTestCase { metadata: metadata ) - await waitForExpectations(timeout: 5.0) + await fulfillment(of: [expectation, storageExpectation], timeout: 1.0) // Then http client sends 5 apply flags batch request, containing 20 records each let request = try XCTUnwrap(partiallyFailingHttpClient.data?.first as? ApplyFlagsRequest) @@ -219,7 +218,7 @@ class FlagApplierWithRetriesTest: XCTestCase { httpClient.testMode = .success await applier.apply(flagName: "flag2", resolveToken: "token1") - await waitForExpectations(timeout: 1.0) + await fulfillment(of: [networkExpectation], timeout: 1.0) // Then 3 post calls are issued (one offline, one batch apply containing 2 reconrds) XCTAssertEqual(httpClient.postCallCounter, 2) @@ -263,7 +262,7 @@ class FlagApplierWithRetriesTest: XCTestCase { // With test mode .success offlineClient.testMode = .success await applier.apply(flagName: "flag2", resolveToken: "token1") - await waitForExpectations(timeout: 1.0) + await fulfillment(of: [storageExpectation, networkExpectation], timeout: 1.0) // Then both requests are marked as sent in cache data let cacheData = await cacheDataInteractor.cache @@ -297,7 +296,7 @@ class FlagApplierWithRetriesTest: XCTestCase { metadata: metadata ) - await waitForExpectations(timeout: 1.0) + await fulfillment(of: [storageExpectation, networkExpectation], timeout: 1.0) // Then storage has been cleaned let storedData = try prefilledStorage.load(defaultValue: CacheData.empty()) @@ -326,7 +325,7 @@ class FlagApplierWithRetriesTest: XCTestCase { // When 100 apply calls are issued // And all http client requests fails with .invalidResponse await hundredApplyCalls(applier: applier, sameToken: true) - await waitForExpectations(timeout: 1.0) + await fulfillment(of: [networkExpectation], timeout: 1.0) // Then strored data is empty let storedData: CacheData = try XCTUnwrap(prefilledStorage.load(defaultValue: CacheData.empty())) @@ -436,7 +435,7 @@ class FlagApplierWithRetriesTest: XCTestCase { // And http client request fails with .invalidResponse await applier.apply(flagName: "flag1", resolveToken: "token1") - await waitForExpectations(timeout: 5.0) + await fulfillment(of: [networkExpectation], timeout: 1.0) // Then 2 resolve event records are stored on disk let storedData: CacheData = try XCTUnwrap(prefilledStorage.load(defaultValue: CacheData.empty())) @@ -500,7 +499,7 @@ class FlagApplierWithRetriesTest: XCTestCase { // When 100 apply calls are issued // And all http client requests fails with .invalidResponse await hundredApplyCalls(applier: applier, sameToken: true) - await waitForExpectations(timeout: 1.0) + await fulfillment(of: [networkExpectation], timeout: 1.0) // Then 1 resolve event record is stored on disk // And 200 flag event records are stored on disk