From c6e2d833e521aca5a67982f9e2b395eefb3e979f Mon Sep 17 00:00:00 2001 From: Andrew Roan Date: Tue, 24 May 2022 09:34:36 -0500 Subject: [PATCH] Fix expectation fulfillment in batch tests fix-expectation-fulfillment-in-batch-tests --- .../BatchRepositoryTests.swift | 51 ++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/Tests/CoreDataRepositoryTests/BatchRepositoryTests.swift b/Tests/CoreDataRepositoryTests/BatchRepositoryTests.swift index 3c6d1d4..cb10545 100644 --- a/Tests/CoreDataRepositoryTests/BatchRepositoryTests.swift +++ b/Tests/CoreDataRepositoryTests/BatchRepositoryTests.swift @@ -88,12 +88,15 @@ final class BatchRepositoryTests: CoreDataXCTestCase { receiveCompletion: { completion in switch completion { case .finished: - exp.fulfill() - default: + break + case .failure: XCTFail("Not expecting failure") + exp.fulfill() } }, - receiveValue: { _ in } + receiveValue: { _ in + exp.fulfill() + } ) .store(in: &cancellables) wait(for: [exp], timeout: 5) @@ -152,12 +155,15 @@ final class BatchRepositoryTests: CoreDataXCTestCase { receiveCompletion: { completion in switch completion { case .finished: - exp.fulfill() - default: + break + case .failure: XCTFail("Not expecting failure") + exp.fulfill() } }, - receiveValue: { _ in } + receiveValue: { _ in + exp.fulfill() + } ) .store(in: &cancellables) wait(for: [exp], timeout: 5) @@ -189,8 +195,8 @@ final class BatchRepositoryTests: CoreDataXCTestCase { receiveCompletion: { completion in switch completion { case .finished: - exp.fulfill() - default: + break + case .failure: XCTFail("Not expecting Failure") exp.fulfill() } @@ -198,6 +204,7 @@ final class BatchRepositoryTests: CoreDataXCTestCase { receiveValue: { result in XCTAssert(result.failed.isEmpty, "None should fail") resultingMovies = result.success + exp.fulfill() } ) .store(in: &cancellables) @@ -227,12 +234,15 @@ final class BatchRepositoryTests: CoreDataXCTestCase { receiveCompletion: { completion in switch completion { case .finished: - exp.fulfill() - default: + break + case .failure: XCTFail("Not expecting Failure") + exp.fulfill() } }, - receiveValue: { _ in } + receiveValue: { _ in + exp.fulfill() + } ) .store(in: &cancellables) wait(for: [exp], timeout: 5) @@ -265,8 +275,8 @@ final class BatchRepositoryTests: CoreDataXCTestCase { receiveCompletion: { completion in switch completion { case .finished: - exp.fulfill() - default: + break + case .failure: XCTFail("Not expecting Failure") exp.fulfill() } @@ -274,6 +284,7 @@ final class BatchRepositoryTests: CoreDataXCTestCase { receiveValue: { result in XCTAssert(result.failed.isEmpty, "None should fail") resultingMovies = result.success + exp.fulfill() } ) .store(in: &cancellables) @@ -304,12 +315,15 @@ final class BatchRepositoryTests: CoreDataXCTestCase { receiveCompletion: { completion in switch completion { case .finished: - exp.fulfill() - default: + break + case .failure: XCTFail("Not expecting failure") + exp.fulfill() } }, - receiveValue: { _ in } + receiveValue: { _ in + exp.fulfill() + } ) .store(in: &cancellables) wait(for: [exp], timeout: 5) @@ -339,14 +353,15 @@ final class BatchRepositoryTests: CoreDataXCTestCase { receiveCompletion: { completion in switch completion { case .finished: - exp.fulfill() - default: + break + case .failure: XCTFail("Not expecting Failure") exp.fulfill() } }, receiveValue: { result in XCTAssert(result.failed.isEmpty, "None should fail") + exp.fulfill() } ) .store(in: &cancellables)