From 52abee5487c03cc5965e5563e8e35f5f2e138520 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 30 Apr 2023 14:17:53 +0200 Subject: [PATCH 1/4] Made the MakeURLRequestUseCase use case available for Linux platforms by importing the FoundationNetworking framework. --- .../Communications/Use Cases/MakeURLRequestUseCase.swift | 6 ++++-- .../Cases/Use Cases/MakeURLRequestUseCaseTests.swift | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Sources/Communications/Use Cases/MakeURLRequestUseCase.swift b/Sources/Communications/Use Cases/MakeURLRequestUseCase.swift index f483f8a..aed0a84 100644 --- a/Sources/Communications/Use Cases/MakeURLRequestUseCase.swift +++ b/Sources/Communications/Use Cases/MakeURLRequestUseCase.swift @@ -10,9 +10,12 @@ // //===----------------------------------------------------------------------===// -#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif + /// This use case generate a url request out of a given endpoint. public struct MakeURLRequestUseCase { @@ -56,4 +59,3 @@ public struct MakeURLRequestUseCase { } } -#endif diff --git a/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift b/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift index ab95f5d..9ffbc4f 100644 --- a/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift +++ b/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift @@ -10,11 +10,14 @@ // //===----------------------------------------------------------------------===// -#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) import Communications import Foundation import XCTest +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif + final class MakeURLRequestUseCaseTests: XCTestCase { // MARK: Properties @@ -28,7 +31,7 @@ final class MakeURLRequestUseCaseTests: XCTestCase { let endpoint = TestEndpoint() // WHEN - let result = try makeURLRequest(endpoint: endpoint) + let result = try makeURLRequest(endpoint: endpoint)`` // THEN XCTAssertNotNil(result) @@ -142,4 +145,3 @@ private struct TestEndpoint: Endpoint { } } -#endif -- 2.47.1 From fe45cd5839c388526c0b588aac838a261b80e8e1 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 30 Apr 2023 14:18:14 +0200 Subject: [PATCH 2/4] Updated some text in the README file. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 27f83fc..c348c0d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ To provide further details about the libraries included in this package: * `Coordination`: protocols to implement the [Coordinator pattern](https://khanlou.com/2015/01/the-coordinator/) and some ready-to-use platform-specific concrete routers; * `Core`: extensions we usually add to the base layer functionality and primitive types provided by the [Swift standard library](https://https://www.swift.org/documentation/#standard-library); * `Dependencies`: a ready-to-use, simple [Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection) mechanism that levers heavily on the [dynamic property wrappers](https://www.hackingwithswift.com/plus/intermediate-swiftui/creating-a-custom-property-wrapper-using-dynamicproperty) provided by the [Swift programming language](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/properties/#Projecting-a-Value-From-a-Property-Wrapper); -* `Persistence`: protocols, extensions and a ready-to-use fetcher class to simplify the building of the [CoreData](https://developer.apple.com/documentation/coredata) persistence layer; +* `Persistence` (*available for Apple platforms only*): protocols, extensions and a ready-to-use fetcher class to simplify the building of the [CoreData](https://developer.apple.com/documentation/coredata) persistence layer; ## Installation @@ -73,6 +73,6 @@ In an opened Xcode project, it is required to follow these steps to install the ### Other considerations -This library is fully supported on Apple platforms: *iOS*, *macOS*, *tvOS*, and *watchOS*. In addition, basic support for *Linux* platform has been added as well, but it is rather limited for the time being, but it is just a matter of time as the Foundation framework is [moving towards cross-platform support](https://www.swift.org/blog/foundation-preview-now-available). +This library is fully supported on Apple platforms: *iOS*, *macOS*, *tvOS*, and *watchOS*. In addition, basic support for *Linux* platform has been added as well, but it is rather limited for the time being. It is just a matter of time, though, as the Foundation framework is [moving towards cross-platform support](https://www.swift.org/blog/foundation-preview-now-available) by moving away from its dependency on legacy Objective-C components. ⚠️ Please notice that this library only supports the [Swift Package Manager](https://www.swift.org/package-manager/), and that support for other dependency managers such as *Cocoapods* and *Carthage* has not been prioritised. -- 2.47.1 From 9f8d9ae300b4e172823bb86f61b9cf419ad78c21 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 30 Apr 2023 14:26:08 +0200 Subject: [PATCH 3/4] Moved the Core library test cases inside the Cases folder. --- Tests/Core/{ => Cases}/Extensions/Bool+InitTests.swift | 0 Tests/Core/{ => Cases}/Extensions/String+EmptyTests.swift | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Tests/Core/{ => Cases}/Extensions/Bool+InitTests.swift (100%) rename Tests/Core/{ => Cases}/Extensions/String+EmptyTests.swift (100%) diff --git a/Tests/Core/Extensions/Bool+InitTests.swift b/Tests/Core/Cases/Extensions/Bool+InitTests.swift similarity index 100% rename from Tests/Core/Extensions/Bool+InitTests.swift rename to Tests/Core/Cases/Extensions/Bool+InitTests.swift diff --git a/Tests/Core/Extensions/String+EmptyTests.swift b/Tests/Core/Cases/Extensions/String+EmptyTests.swift similarity index 100% rename from Tests/Core/Extensions/String+EmptyTests.swift rename to Tests/Core/Cases/Extensions/String+EmptyTests.swift -- 2.47.1 From f84f95635a6f86a26a7a4ba8fd177ae06aa3ee1b Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 30 Apr 2023 14:26:56 +0200 Subject: [PATCH 4/4] Moved the TestEndpoint endpoint to its own file. --- .../MakeURLRequestUseCaseTests.swift | 33 +------------- .../Helpers/Endpoints/TestEndpoint.swift | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+), 32 deletions(-) create mode 100644 Tests/Communications/Helpers/Endpoints/TestEndpoint.swift diff --git a/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift b/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift index 9ffbc4f..3fdd850 100644 --- a/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift +++ b/Tests/Communications/Cases/Use Cases/MakeURLRequestUseCaseTests.swift @@ -31,7 +31,7 @@ final class MakeURLRequestUseCaseTests: XCTestCase { let endpoint = TestEndpoint() // WHEN - let result = try makeURLRequest(endpoint: endpoint)`` + let result = try makeURLRequest(endpoint: endpoint) // THEN XCTAssertNotNil(result) @@ -114,34 +114,3 @@ final class MakeURLRequestUseCaseTests: XCTestCase { } } - -// MARK: - TestEndpoint - -private struct TestEndpoint: Endpoint { - - // MARK: Properties - - let scheme: String = "http" - let host: String = "www.something.com" - let port: Int? - let path: String = "/path/to/endpoint" - let parameters: Parameters - let method: HTTPRequestMethod = .get - let headers: Headers - let body: Data? - - // MARK: Initialisers - - init( - port: Int? = nil, - parameters: Parameters = [:], - headers: Headers = [:], - body: Data? = nil - ) { - self.port = port - self.parameters = parameters - self.headers = headers - self.body = body - } - -} diff --git a/Tests/Communications/Helpers/Endpoints/TestEndpoint.swift b/Tests/Communications/Helpers/Endpoints/TestEndpoint.swift new file mode 100644 index 0000000..f7f5ce5 --- /dev/null +++ b/Tests/Communications/Helpers/Endpoints/TestEndpoint.swift @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the SwiftLibs open source project +// +// Copyright (c) 2023 Röck+Cöde VoF. and the SwiftLibs project authors +// Licensed under the EUPL 1.2 or later. +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of SwiftLibs project authors +// +//===----------------------------------------------------------------------===// + +import Communications +import Foundation + +struct TestEndpoint: Endpoint { + + // MARK: Properties + + let scheme: String = "http" + let host: String = "www.something.com" + let port: Int? + let path: String = "/path/to/endpoint" + let parameters: Parameters + let method: HTTPRequestMethod = .get + let headers: Headers + let body: Data? + + // MARK: Initialisers + + init( + port: Int? = nil, + parameters: Parameters = [:], + headers: Headers = [:], + body: Data? = nil + ) { + self.port = port + self.parameters = parameters + self.headers = headers + self.body = body + } + +} -- 2.47.1