diff --git a/.gitignore b/.gitignore index cbc442c8..3984f51a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,10 @@ ## Build generated build/ DerivedData/ +CoverageReports/ Docs/swift_output/ CoverageReports/ +Package.resolved ## Various settings *.pbxuser diff --git a/NodeKit.framework.coverage.txt b/NodeKit.framework.coverage.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/NodeKit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/NodeKit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index e73431ff..00000000 --- a/NodeKit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,15 +0,0 @@ -{ - "originHash" : "1d2e6911b0388532b33f83466feee8deadacbc6241719180eb45fd871a5091ac", - "pins" : [ - { - "identity" : "coreevents", - "kind" : "remoteSourceControl", - "location" : "https://github.com/surfstudio/CoreEvents", - "state" : { - "revision" : "35ea2dac82e61d7fa1fab1b10e0038d31ff3fd53", - "version" : "2.0.2" - } - } - ], - "version" : 3 -} diff --git a/NodeKitTests.xctest.coverage.txt b/NodeKitTests.xctest.coverage.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/NodeKitTests/UnitTests/LoadIndicatableNodeTests.swift b/NodeKitTests/UnitTests/LoadIndicatableNodeTests.swift index 1df416b8..2c988150 100644 --- a/NodeKitTests/UnitTests/LoadIndicatableNodeTests.swift +++ b/NodeKitTests/UnitTests/LoadIndicatableNodeTests.swift @@ -89,11 +89,12 @@ final class LoadIndicatableNodeTests: XCTestCase { XCTAssertEqual(error, .firstError) } + @MainActor func testAsyncProcess_thenIndicatorIncremented() async { // given var count = 0 - let expectation = expectation(description: "result") + let expectation = expectation(description: #function) nextNodeMock.stubbedAsyncProccessResult = .success(1) nextNodeMock.stubbedAsyncProcessRunFunction = { count += 1 @@ -113,7 +114,7 @@ final class LoadIndicatableNodeTests: XCTestCase { _ = await sut.process(1, logContext: logContextMock) } - await fulfillment(of: [expectation], timeout: 0.2) + await fulfillment(of: [expectation], timeout: 3) // then diff --git a/NodeKitTests/UnitTests/Node/AsyncNodeTests.swift b/NodeKitTests/UnitTests/Node/AsyncNodeTests.swift index ae477730..ee1d9793 100644 --- a/NodeKitTests/UnitTests/Node/AsyncNodeTests.swift +++ b/NodeKitTests/UnitTests/Node/AsyncNodeTests.swift @@ -83,7 +83,7 @@ final class AsyncNodeTests: XCTestCase { // given let sut = AsyncNodeMock() - let expectation = expectation(description: "result") + let expectation = expectation(description: #function) let expectedInput = 15 let expectedResult = 21 let logContext = LoggingContextMock() @@ -103,7 +103,7 @@ final class AsyncNodeTests: XCTestCase { }) .store(in: &cancellable) - await fulfillment(of: [expectation], timeout: 0.1) + await fulfillment(of: [expectation], timeout: 3) // then diff --git a/NodeKitTests/UnitTests/Node/AsyncStreamNodeTests.swift b/NodeKitTests/UnitTests/Node/AsyncStreamNodeTests.swift index dea24734..9f750e41 100644 --- a/NodeKitTests/UnitTests/Node/AsyncStreamNodeTests.swift +++ b/NodeKitTests/UnitTests/Node/AsyncStreamNodeTests.swift @@ -119,7 +119,7 @@ final class AsyncStreamNodeTests: XCTestCase { // given let sut = AsyncStreamNodeMock() - let expectation = expectation(description: "result") + let expectation = expectation(description: #function) let expectedInput = 43 let expectedResults: [Result] = [ @@ -154,7 +154,7 @@ final class AsyncStreamNodeTests: XCTestCase { node.process(expectedInput, logContext: logContextMock) - await fulfillment(of: [expectation], timeout: 0.1) + await fulfillment(of: [expectation], timeout: 3) // then diff --git a/NodeKitTests/UnitTests/Node/Combine/AsyncCombineNodeTests.swift b/NodeKitTests/UnitTests/Node/Combine/AsyncCombineNodeTests.swift index cc7f2e3d..1d49fcda 100644 --- a/NodeKitTests/UnitTests/Node/Combine/AsyncCombineNodeTests.swift +++ b/NodeKitTests/UnitTests/Node/Combine/AsyncCombineNodeTests.swift @@ -42,8 +42,9 @@ final class AsyncCombineNodeTests: XCTestCase { // MARK: - Tests + @MainActor func testnodeResultPublisher_withPublisherOnMainQueue_thenResultsReceivedOnMainQueue() async { - let expectation = expectation(description: "result") + let expectation = expectation(description: #function) var isMainThread = false @@ -58,7 +59,7 @@ final class AsyncCombineNodeTests: XCTestCase { }) .store(in: &cancellable) - await fulfillment(of: [expectation], timeout: 0.1) + await fulfillment(of: [expectation], timeout: 3) // then @@ -68,7 +69,7 @@ final class AsyncCombineNodeTests: XCTestCase { func testNodeResultPublisher_onCustomQueue_thenDataReceivedOnCustomQueue() async { // given - let expectation = expectation(description: "result") + let expectation = expectation(description: #function) let expectedQueueName = "Test Process Queue" let queue = DispatchQueue(label: expectedQueueName) @@ -85,17 +86,18 @@ final class AsyncCombineNodeTests: XCTestCase { }) .store(in: &cancellable) - await fulfillment(of: [expectation], timeout: 0.1) + await fulfillment(of: [expectation], timeout: 3) // then XCTAssertEqual(queueName, expectedQueueName) } + @MainActor func testNodeResultPublisher_thenNextNodeCalled() async throws { // given - let expectation = expectation(description: "result") + let expectation = expectation(description: #function) let expectedInput = 7 let expectedResult: NodeResult = .success(8) @@ -109,7 +111,7 @@ final class AsyncCombineNodeTests: XCTestCase { }) .store(in: &cancellable) - await fulfillment(of: [expectation], timeout: 0.1) + await fulfillment(of: [expectation], timeout: 3) // then @@ -119,10 +121,11 @@ final class AsyncCombineNodeTests: XCTestCase { XCTAssertEqual(input.data, expectedInput) } + @MainActor func testNodeResultPublisher_whenResultIsSuccess_thenSuccessResultReceived() async throws { // given - let expectation = expectation(description: "result") + let expectation = expectation(description: #function) let expectedResult = 8 var result: NodeResult? @@ -138,7 +141,7 @@ final class AsyncCombineNodeTests: XCTestCase { }) .store(in: &cancellable) - await fulfillment(of: [expectation], timeout: 0.1) + await fulfillment(of: [expectation], timeout: 3) // then @@ -147,11 +150,12 @@ final class AsyncCombineNodeTests: XCTestCase { XCTAssertEqual(value, expectedResult) } + @MainActor func testNodeResultPublisher_whithMultipleSubscriptions_thenResultsReceived() async throws { // given - let expectation1 = expectation(description: "result1") - let expectation2 = expectation(description: "result2") + let expectation1 = expectation(description: #function + "1") + let expectation2 = expectation(description: #function + "2") let expectedResult = 8 var result1: NodeResult? @@ -177,7 +181,7 @@ final class AsyncCombineNodeTests: XCTestCase { }) .store(in: &cancellable) - await fulfillment(of: [expectation1, expectation2], timeout: 0.1) + await fulfillment(of: [expectation1, expectation2], timeout: 3) // then @@ -188,10 +192,11 @@ final class AsyncCombineNodeTests: XCTestCase { XCTAssertEqual(value2, expectedResult) } + @MainActor func testNodeResultPublisher_whenResultIsFailure_thenFailureResultReceived() async throws { // given - let expectation = expectation(description: "result") + let expectation = expectation(description: #function) var result: NodeResult? @@ -206,7 +211,7 @@ final class AsyncCombineNodeTests: XCTestCase { }) .store(in: &cancellable) - await fulfillment(of: [expectation], timeout: 0.1) + await fulfillment(of: [expectation], timeout: 3) // then diff --git a/NodeKitTests/UnitTests/Node/Combine/AsyncStreamCombineNodeTests.swift b/NodeKitTests/UnitTests/Node/Combine/AsyncStreamCombineNodeTests.swift index 5b533b69..b3744940 100644 --- a/NodeKitTests/UnitTests/Node/Combine/AsyncStreamCombineNodeTests.swift +++ b/NodeKitTests/UnitTests/Node/Combine/AsyncStreamCombineNodeTests.swift @@ -42,10 +42,11 @@ final class AsyncStreamCombineNodeTests: XCTestCase { // MARK: - Tests + @MainActor func testProcess_withPublisherOnMainQueue_thenResultsReceivedOnMainQueue() async { // given - let expectation = expectation(description: "result") + let expectation = expectation(description: #function) var isMainThread = false @@ -67,7 +68,7 @@ final class AsyncStreamCombineNodeTests: XCTestCase { sut.process(12, logContext: logContextMock) - await fulfillment(of: [expectation], timeout: 0.1) + await fulfillment(of: [expectation], timeout: 3) // then @@ -77,7 +78,7 @@ final class AsyncStreamCombineNodeTests: XCTestCase { func testProcess_withPublisherOnCustomQueue_thenResultsReceivedOnCustomQueue() async { // given - let expectation = expectation(description: "result") + let expectation = expectation(description: #function) let expectedLabel = "Test Process Queue" let queue = DispatchQueue(label: expectedLabel) @@ -103,7 +104,7 @@ final class AsyncStreamCombineNodeTests: XCTestCase { sut.process(12, logContext: logContextMock) - await fulfillment(of: [expectation], timeout: 0.1) + await fulfillment(of: [expectation], timeout: 3) // then @@ -111,10 +112,11 @@ final class AsyncStreamCombineNodeTests: XCTestCase { XCTAssertEqual(queueLabel, expectedLabel) } + @MainActor func testProcess_thenResultsReceived() async throws { // given - let expectation = expectation(description: "result") + let expectation = expectation(description: #function) let expectedInput = 43 let expectedResults: [Result] = [ @@ -147,7 +149,7 @@ final class AsyncStreamCombineNodeTests: XCTestCase { sut.process(expectedInput, logContext: logContextMock) - await fulfillment(of: [expectation], timeout: 0.1) + await fulfillment(of: [expectation], timeout: 3) // then @@ -162,11 +164,12 @@ final class AsyncStreamCombineNodeTests: XCTestCase { ) } + @MainActor func testProcess_withMultipleSubsciptions_thenResultsReceived() async { // given - let expectation1 = expectation(description: "result1") - let expectation2 = expectation(description: "result2") + let expectation1 = expectation(description: #function + "1") + let expectation2 = expectation(description: #function + "2") let expectedResults: [Result] = [ .success(500), @@ -216,7 +219,7 @@ final class AsyncStreamCombineNodeTests: XCTestCase { sut.process(1, logContext: logContextMock) - await fulfillment(of: [expectation1, expectation2], timeout: 1) + await fulfillment(of: [expectation1, expectation2], timeout: 3) // then diff --git a/NodeKitTests/UnitTests/Node/Combine/CombineNodeTests.swift b/NodeKitTests/UnitTests/Node/Combine/CombineNodeTests.swift index c4adb566..76b557d2 100644 --- a/NodeKitTests/UnitTests/Node/Combine/CombineNodeTests.swift +++ b/NodeKitTests/UnitTests/Node/Combine/CombineNodeTests.swift @@ -13,6 +13,7 @@ final class CombineNodeTests: XCTestCase { // MARK: - Tests + @MainActor func testNodeResultPublisher_withVoid_thenMainMethodCalled() throws { // given @@ -33,6 +34,7 @@ final class CombineNodeTests: XCTestCase { XCTAssertEqual(scheduler, .main) } + @MainActor func testNodeResultPublisher_withData_thenMainMethodCalled() throws { // given @@ -80,6 +82,7 @@ final class CombineNodeTests: XCTestCase { XCTAssertEqual(scheduler, queue) } + @MainActor func testNodeResultPublisher_withData_andLogContext_thenMainMethodCalled() throws { // given diff --git a/NodeKitTests/UnitTests/RequestSenderNodeTests.swift b/NodeKitTests/UnitTests/RequestSenderNodeTests.swift index dc275430..a3a40c7e 100644 --- a/NodeKitTests/UnitTests/RequestSenderNodeTests.swift +++ b/NodeKitTests/UnitTests/RequestSenderNodeTests.swift @@ -48,23 +48,16 @@ final class RequestSenderNodeTests: XCTestCase { func testAsynProcess_thenLoadingStarted() async { // given - - let expectation = expectation(description: "result") URLProtocolMock.stubbedError = MockError.firstError nextNodeMock.stubbedAsyncProccessResult = .success(15) // when - Task { - _ = await sut.process( - URLRequest(url: URL(string: "www.testprocess.com")!), - logContext: logContextMock - ) - expectation.fulfill() - } - - await fulfillment(of: [expectation], timeout: 0.1) + _ = await sut.process( + URLRequest(url: URL(string: "www.testprocess.com")!), + logContext: logContextMock + ) // then @@ -74,7 +67,6 @@ final class RequestSenderNodeTests: XCTestCase { func testAsyncProcess_whenResponseFailure_thenNextCalled() async throws { // given - let expectation = expectation(description: "result") let url = URL(string: "www.testprocess.com")! let expectedRequest = URLRequest(url: url) @@ -83,12 +75,7 @@ final class RequestSenderNodeTests: XCTestCase { // when - Task { - _ = await sut.process(expectedRequest, logContext: logContextMock) - expectation.fulfill() - } - - await fulfillment(of: [expectation], timeout: 0.1) + _ = await sut.process(expectedRequest, logContext: logContextMock) // then @@ -104,22 +91,15 @@ final class RequestSenderNodeTests: XCTestCase { func testAsyncProcess_whenFailure_thenDataTaskSaved() async throws { // given - let expectation = expectation(description: "result") - URLProtocolMock.stubbedError = MockError.firstError nextNodeMock.stubbedAsyncProccessResult = .success(15) // when - Task { - _ = await sut.process( - URLRequest(url: URL(string: "www.testprocess.com")!), - logContext: logContextMock - ) - expectation.fulfill() - } - - await fulfillment(of: [expectation], timeout: 0.1) + _ = await sut.process( + URLRequest(url: URL(string: "www.testprocess.com")!), + logContext: logContextMock + ) // then @@ -130,8 +110,6 @@ final class RequestSenderNodeTests: XCTestCase { func testAsyncProcess_whenSuccess_thenDataTaskSaved() async throws { // given - let expectation = expectation(description: "result") - URLProtocolMock.stubbedRequestHandler = { _ in return (HTTPURLResponse(), Data()) } @@ -139,15 +117,10 @@ final class RequestSenderNodeTests: XCTestCase { // when - Task { - _ = await sut.process( - URLRequest(url: URL(string: "www.testprocess.com")!), - logContext: logContextMock - ) - expectation.fulfill() - } - - await fulfillment(of: [expectation], timeout: 0.1) + _ = await sut.process( + URLRequest(url: URL(string: "www.testprocess.com")!), + logContext: logContextMock + ) // then @@ -162,7 +135,6 @@ final class RequestSenderNodeTests: XCTestCase { func testAsyncProcess_whenResponseSuccess_thenNextCalled() async throws { // given - let expectation = expectation(description: "result") let url = URL(string: "www.testprocess.com")! let expectedData = "TestData".data(using: .utf8)! let expectedRequest = URLRequest(url: url) @@ -181,12 +153,7 @@ final class RequestSenderNodeTests: XCTestCase { // when - Task { - _ = await sut.process(expectedRequest, logContext: logContextMock) - expectation.fulfill() - } - - await fulfillment(of: [expectation], timeout: 0.1) + _ = await sut.process(expectedRequest, logContext: logContextMock) // then @@ -202,44 +169,30 @@ final class RequestSenderNodeTests: XCTestCase { XCTAssertEqual(inputValue, expectedData) } - @MainActor func testAsyncProcess_nextReturnsSuccess_thenSuccessReceived() async throws { // given - let expectation = expectation(description: "result") let expectedResult = 55 let url = URL(string: "www.testprocess.com")! let expectedRequest = URLRequest(url: url) - var result: NodeResult? - URLProtocolMock.stubbedError = MockError.secondError nextNodeMock.stubbedAsyncProccessResult = .success(expectedResult) // when - Task { - result = await sut.process(expectedRequest, logContext: logContextMock) - expectation.fulfill() - } - - await fulfillment(of: [expectation], timeout: 0.1) + let result = await sut.process(expectedRequest, logContext: logContextMock) // then - let value = try XCTUnwrap(result?.value) + let value = try XCTUnwrap(result.value) XCTAssertEqual(value, expectedResult) } - @MainActor func testAsyncProcess_nextReturnsFailure_thenFailureReceived() async throws { // given - let expectation = expectation(description: "result") - - var result: NodeResult? - URLProtocolMock.stubbedRequestHandler = { _ in return (HTTPURLResponse(), Data()) } @@ -248,19 +201,14 @@ final class RequestSenderNodeTests: XCTestCase { // when - Task { - result = await sut.process( - URLRequest(url: URL(string: "www.testprocess.com")!), - logContext: logContextMock - ) - expectation.fulfill() - } - - await fulfillment(of: [expectation], timeout: 0.1) + let result = await sut.process( + URLRequest(url: URL(string: "www.testprocess.com")!), + logContext: logContextMock + ) // then - let error = try XCTUnwrap(result?.error as? MockError) + let error = try XCTUnwrap(result.error as? MockError) XCTAssertEqual(error, .secondError) } diff --git a/Package.resolved b/Package.resolved deleted file mode 100644 index c41c5fdc..00000000 --- a/Package.resolved +++ /dev/null @@ -1,16 +0,0 @@ -{ - "object": { - "pins": [ - { - "package": "CoreEvents", - "repositoryURL": "https://github.com/surfstudio/CoreEvents", - "state": { - "branch": null, - "revision": "35ea2dac82e61d7fa1fab1b10e0038d31ff3fd53", - "version": "2.0.2" - } - } - ] - }, - "version": 1 -}