From 9acab784a32f9f6ff5ef3e5c9c275162fade82d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulas=CC=A7=20Sancak?= Date: Mon, 21 Oct 2024 13:35:36 +0300 Subject: [PATCH] Update package for Swift 6 --- Package.resolved | 4 +- Package.swift | 4 +- Sources/WPSwift/API/WPClient.swift | 4 +- .../WPSwift/API/WPClientConfiguration.swift | 18 +++--- Sources/WPSwift/API/WPEndpoint.swift | 6 +- Sources/WPSwift/Models/APIInfo.swift | 2 +- Sources/WPSwift/Models/AnyCodable.swift | 2 +- Sources/WPSwift/Models/Author.swift | 2 +- Sources/WPSwift/Models/Category.swift | 6 +- Sources/WPSwift/Models/EmbeddedContent.swift | 2 +- Sources/WPSwift/Models/EmptyModel.swift | 2 +- Sources/WPSwift/Models/FeaturedMedia.swift | 6 +- Sources/WPSwift/Models/Params.swift | 18 +++--- Sources/WPSwift/Models/Post.swift | 22 +++---- Sources/WPSwift/Models/SimplePost.swift | 2 +- .../Repositories/APIInfoRepository.swift | 2 +- .../Repositories/CategoriesRepository.swift | 2 +- .../Repositories/PostsRepository.swift | 2 +- Sources/WPSwift/WPSwift.swift | 8 +-- .../APITests/APIClientTests.swift | 4 +- .../Mocks/MockedURLProtocol.swift | 2 +- .../WPSwiftTests/Mocks/SimplePost+Mock.swift | 12 ++-- .../PostsRepositoryTests.swift | 60 +++++++++---------- 23 files changed, 96 insertions(+), 96 deletions(-) diff --git a/Package.resolved b/Package.resolved index 1c015e9..dee5d93 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/rocxteady/Resting.git", "state" : { - "revision" : "667c7e7903e41ccd4ab8a39f4df0570a29f49ead", - "version" : "0.0.9" + "revision" : "d0e2284183fd85a820f915b33f08ce323e2d2823", + "version" : "1.0.0-beta.1" } } ], diff --git a/Package.swift b/Package.swift index 4206638..0b40735 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.8 +// swift-tools-version: 6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -14,7 +14,7 @@ let package = Package( targets: ["WPSwift"]), ], dependencies: [ - .package(url: "https://github.com/rocxteady/Resting.git", .upToNextMajor(from: "0.0.9")), + .package(url: "https://github.com/rocxteady/Resting.git", .upToNextMajor(from: "1.0.0-beta.1")), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Sources/WPSwift/API/WPClient.swift b/Sources/WPSwift/API/WPClient.swift index e27405b..0a74eb3 100644 --- a/Sources/WPSwift/API/WPClient.swift +++ b/Sources/WPSwift/API/WPClient.swift @@ -9,7 +9,7 @@ import Foundation import Combine import Resting -public enum NetworkError: LocalizedError { +public enum NetworkError: LocalizedError, Sendable { case urlMalformed case api(Error) case unknown @@ -26,7 +26,7 @@ public enum NetworkError: LocalizedError { } } -public struct WPClient { +public struct WPClient: Sendable { private let restClient: RestClient private let requestConfig: RequestConfiguration diff --git a/Sources/WPSwift/API/WPClientConfiguration.swift b/Sources/WPSwift/API/WPClientConfiguration.swift index 33d14e0..5cbcb95 100644 --- a/Sources/WPSwift/API/WPClientConfiguration.swift +++ b/Sources/WPSwift/API/WPClientConfiguration.swift @@ -8,13 +8,13 @@ import Foundation import Resting -struct WPClientConfiguration { - enum ParameterType { - case object([String: Any]) - case model(Encodable) +struct WPClientConfiguration: Sendable { + enum ParameterType: Sendable { + case object([String: any Sendable]) + case model(Encodable & Sendable) } - enum EndpointType { + enum EndpointType: Sendable { case base(baseURL: String, endpoint: String) case endpoint(String) } @@ -24,7 +24,7 @@ struct WPClientConfiguration { let headers: [String: String]? let parameterType: ParameterType? - init(endpoint: String, method: HTTPMethod = .get, parameters: [String : Any]?, encoding: HTTPEncoding = .urlEncoded, headers: [String: String]? = nil) { + init(endpoint: String, method: HTTPMethod = .get, parameters: [String : any Sendable]?, encoding: HTTPEncoding = .urlEncoded, headers: [String: String]? = nil) { self.endpointType = .endpoint(endpoint) self.method = method self.encoding = encoding @@ -36,7 +36,7 @@ struct WPClientConfiguration { self.headers = headers } - init(endpoint: String, method: HTTPMethod = .post, requestModel: Encodable?, encoding: HTTPEncoding = .json, headers: [String: String]? = nil) { + init(endpoint: String, method: HTTPMethod = .post, requestModel: (Encodable & Sendable)?, encoding: HTTPEncoding = .json, headers: [String: String]? = nil) { self.endpointType = .endpoint(endpoint) self.method = method self.encoding = encoding @@ -48,7 +48,7 @@ struct WPClientConfiguration { self.headers = headers } - init(baseURL: String, endpoint: String, method: HTTPMethod = .get, parameters: [String : Any]?, encoding: HTTPEncoding = .urlEncoded, headers: [String: String]? = nil) { + init(baseURL: String, endpoint: String, method: HTTPMethod = .get, parameters: [String : any Sendable]?, encoding: HTTPEncoding = .urlEncoded, headers: [String: String]? = nil) { self.endpointType = .base(baseURL: baseURL, endpoint: endpoint) self.method = method self.encoding = encoding @@ -60,7 +60,7 @@ struct WPClientConfiguration { self.headers = headers } - init(baseURL: String, endpoint: String, method: HTTPMethod = .post, requestModel: Encodable?, encoding: HTTPEncoding = .json, headers: [String: String]? = nil) { + init(baseURL: String, endpoint: String, method: HTTPMethod = .post, requestModel: (Encodable & Sendable)?, encoding: HTTPEncoding = .json, headers: [String: String]? = nil) { self.endpointType = .base(baseURL: baseURL, endpoint: endpoint) self.method = method self.encoding = encoding diff --git a/Sources/WPSwift/API/WPEndpoint.swift b/Sources/WPSwift/API/WPEndpoint.swift index d9d3d74..977cfa0 100644 --- a/Sources/WPSwift/API/WPEndpoint.swift +++ b/Sources/WPSwift/API/WPEndpoint.swift @@ -7,8 +7,8 @@ import Foundation -enum WPEndpoint { - enum Posts { +enum WPEndpoint: Sendable { + enum Posts: Sendable { case posts case post(id: Int) case search @@ -25,7 +25,7 @@ enum WPEndpoint { } } - enum Categories { + enum Categories: Sendable { case categories case category(id: Int) diff --git a/Sources/WPSwift/Models/APIInfo.swift b/Sources/WPSwift/Models/APIInfo.swift index 515375d..b70f507 100644 --- a/Sources/WPSwift/Models/APIInfo.swift +++ b/Sources/WPSwift/Models/APIInfo.swift @@ -7,7 +7,7 @@ import Foundation -public struct APIInfo: Decodable { +public struct APIInfo: Decodable, Sendable { public let name: String public let description: String? public let url: String? diff --git a/Sources/WPSwift/Models/AnyCodable.swift b/Sources/WPSwift/Models/AnyCodable.swift index 837dc39..2a84cbf 100644 --- a/Sources/WPSwift/Models/AnyCodable.swift +++ b/Sources/WPSwift/Models/AnyCodable.swift @@ -9,7 +9,7 @@ import Foundation // Because the WordPress API can return meta data with different value types, // we can use the following general-purpose Codable struct: -public enum AnyCodable: Codable { +public enum AnyCodable: Codable, Sendable { case double(Double) case string(String) case bool(Bool) diff --git a/Sources/WPSwift/Models/Author.swift b/Sources/WPSwift/Models/Author.swift index 1454752..af9c8e2 100644 --- a/Sources/WPSwift/Models/Author.swift +++ b/Sources/WPSwift/Models/Author.swift @@ -7,7 +7,7 @@ import Foundation -public struct Author: Decodable { +public struct Author: Decodable, Sendable { public let id: Int public let name: String public let description: String diff --git a/Sources/WPSwift/Models/Category.swift b/Sources/WPSwift/Models/Category.swift index d141665..7051a81 100644 --- a/Sources/WPSwift/Models/Category.swift +++ b/Sources/WPSwift/Models/Category.swift @@ -7,7 +7,7 @@ import Foundation -public struct PostCategory: Decodable { +public struct PostCategory: Decodable, Sendable { public let id: Int public let count: Int public let description: String @@ -25,7 +25,7 @@ public struct PostCategory: Decodable { } } -public struct PostCategoryToCreate: Encodable { +public struct PostCategoryToCreate: Encodable, Sendable { public let description: String public let name: String public let parent: Int @@ -37,7 +37,7 @@ public struct PostCategoryToCreate: Encodable { } } -public struct PostCategoryToUpdate: Encodable { +public struct PostCategoryToUpdate: Encodable, Sendable { public let id: Int public let description: String public let name: String diff --git a/Sources/WPSwift/Models/EmbeddedContent.swift b/Sources/WPSwift/Models/EmbeddedContent.swift index 82d6601..cfea8e8 100644 --- a/Sources/WPSwift/Models/EmbeddedContent.swift +++ b/Sources/WPSwift/Models/EmbeddedContent.swift @@ -7,7 +7,7 @@ import Foundation -public struct EmbeddedContent: Decodable { +public struct EmbeddedContent: Decodable, Sendable { public var author: Author? { _author?.first } diff --git a/Sources/WPSwift/Models/EmptyModel.swift b/Sources/WPSwift/Models/EmptyModel.swift index da95c83..0a28153 100644 --- a/Sources/WPSwift/Models/EmptyModel.swift +++ b/Sources/WPSwift/Models/EmptyModel.swift @@ -7,6 +7,6 @@ import Foundation -public struct EmptyModel: Encodable { +public struct EmptyModel: Encodable, Sendable { public init() {} } diff --git a/Sources/WPSwift/Models/FeaturedMedia.swift b/Sources/WPSwift/Models/FeaturedMedia.swift index 75839f0..7fb8385 100644 --- a/Sources/WPSwift/Models/FeaturedMedia.swift +++ b/Sources/WPSwift/Models/FeaturedMedia.swift @@ -7,7 +7,7 @@ import Foundation -public struct FeaturedMedia: Codable { +public struct FeaturedMedia: Codable, Sendable { public let id: Int public let title: RenderedContent public let caption: RenderedContent @@ -36,7 +36,7 @@ public struct FeaturedMedia: Codable { } } -public struct MediaDetails: Codable { +public struct MediaDetails: Codable, Sendable { public let width:Int public let height: Int public let sizes: [String: Size] @@ -53,7 +53,7 @@ public struct MediaDetails: Codable { } // MARK: - Size -public struct Size: Codable { +public struct Size: Codable, Sendable { public let width: Int public let height: Int public let sourceURL: String diff --git a/Sources/WPSwift/Models/Params.swift b/Sources/WPSwift/Models/Params.swift index a4a7b33..47ccc21 100644 --- a/Sources/WPSwift/Models/Params.swift +++ b/Sources/WPSwift/Models/Params.swift @@ -7,18 +7,18 @@ import Foundation -public enum OrderType: String, Decodable { +public enum OrderType: String, Decodable, Sendable { case ascending = "asc" case descending = "desc" } -extension [String: Any] { - static func createParamsForPost(categories: [Int] = [], categoriesToExclude: [Int] = [], tags: [Int] = [], tagsToExclude: [Int] = []) -> [String: Any] { +extension [String: any Sendable] { + static func createParamsForPost(categories: [Int] = [], categoriesToExclude: [Int] = [], tags: [Int] = [], tagsToExclude: [Int] = []) -> [String: any Sendable] { let categories = categories.map { "\($0)" }.joined(separator: ",") let categoriesToExclude = categoriesToExclude.map { "\($0)" }.joined(separator: ",") let tags = tags.map { "\($0)" }.joined(separator: ",") let tagsToExclude = tagsToExclude.map { "\($0)" }.joined(separator: ",") - var params: [String: Any] = [ + var params: [String: any Sendable] = [ "_embed": "", "_fields":"id,date_gmt,modified_gmt,status,title,content,contentHTML,excerpt,author,featured_media,comment_status,categories,tags,link,_links" ] @@ -37,13 +37,13 @@ extension [String: Any] { return params } - static func createParamsForPosts(page: Int = 1, perPage: Int = 10, order: OrderType = .descending, categories: [Int]? = nil, categoriesToExclude: [Int]? = nil, tags: [Int]? = nil, tagsToExclude: [Int]? = nil, include: [Int]? = nil) -> [String: Any] { + static func createParamsForPosts(page: Int = 1, perPage: Int = 10, order: OrderType = .descending, categories: [Int]? = nil, categoriesToExclude: [Int]? = nil, tags: [Int]? = nil, tagsToExclude: [Int]? = nil, include: [Int]? = nil) -> [String: any Sendable] { let categories = categories?.map { "\($0)" }.joined(separator: ",") let categoriesToExclude = categoriesToExclude?.map { "\($0)" }.joined(separator: ",") let tags = tags?.map { "\($0)" }.joined(separator: ",") let tagsToExclude = tagsToExclude?.map { "\($0)" }.joined(separator: ",") let include = include?.map { "\($0)" }.joined(separator: ",") - var params: [String: Any] = [ + var params: [String: any Sendable] = [ "page": page, "per_page": perPage, "order": order.rawValue, @@ -68,7 +68,7 @@ extension [String: Any] { return params } - static func createParamsForSearchPosts(term: String, page: Int = 1, perPage: Int = 10) -> [String: Any] { + static func createParamsForSearchPosts(term: String, page: Int = 1, perPage: Int = 10) -> [String: any Sendable] { [ "search": term, "page": page, @@ -78,7 +78,7 @@ extension [String: Any] { ] } - static func createParamsForCategories(page: Int = 1, perPage: Int = 100, order: OrderType = .descending) -> [String: Any] { + static func createParamsForCategories(page: Int = 1, perPage: Int = 100, order: OrderType = .descending) -> [String: any Sendable] { [ "page": page, "per_page": perPage, @@ -89,7 +89,7 @@ extension [String: Any] { ] } - static func createParamsForCategory() -> [String: Any] { + static func createParamsForCategory() -> [String: any Sendable] { [ "_fields":"id,count,description,link,name,parent" ] diff --git a/Sources/WPSwift/Models/Post.swift b/Sources/WPSwift/Models/Post.swift index fb00e3b..f257283 100644 --- a/Sources/WPSwift/Models/Post.swift +++ b/Sources/WPSwift/Models/Post.swift @@ -7,7 +7,7 @@ import Foundation -public enum CommentStatus: String, Decodable { +public enum CommentStatus: String, Codable, Sendable { case `open` case closed case close @@ -17,7 +17,7 @@ public enum CommentStatus: String, Decodable { } } -public struct Post: Decodable { +public struct Post: Decodable, Sendable { public let id: Int public let date: Date? public let modified: Date? @@ -107,7 +107,7 @@ public struct Post: Decodable { } } -public struct PostToCreate: Encodable { +public struct PostToCreate: Encodable, Sendable { public let title: RenderedContent public let content: RenderedContent public let format: String? @@ -115,12 +115,12 @@ public struct PostToCreate: Encodable { public let excerpt: RenderedContent? public let status: String? public let password: String? - public let comment_status: String? + public let commentStatus: CommentStatus? public let ping_status: String? public let categories: [Int] public let tags: [Int] - public init(title: RenderedContent, content: RenderedContent, format: String? = nil, sticky: Bool? = nil, excerpt: RenderedContent? = nil, status: String? = nil, password: String? = nil, comment_status: String? = nil, ping_status: String? = nil, categories: [Int], tags: [Int]) { + public init(title: RenderedContent, content: RenderedContent, format: String? = nil, sticky: Bool? = nil, excerpt: RenderedContent? = nil, status: String? = nil, password: String? = nil, commentStatus: CommentStatus? = nil, ping_status: String? = nil, categories: [Int], tags: [Int]) { self.title = title self.content = content self.format = format @@ -128,14 +128,14 @@ public struct PostToCreate: Encodable { self.excerpt = excerpt self.status = status self.password = password - self.comment_status = comment_status + self.commentStatus = commentStatus self.ping_status = ping_status self.categories = categories self.tags = tags } } -public struct PostToUpdate: Encodable { +public struct PostToUpdate: Encodable, Sendable { public let id: Int public let title: RenderedContent public let content: RenderedContent @@ -144,12 +144,12 @@ public struct PostToUpdate: Encodable { public let excerpt: RenderedContent? public let status: String? public let password: String? - public let comment_status: String? + public let commentStatus: CommentStatus? public let ping_status: String? public let categories: [Int] public let tags: [Int] - public init(id: Int, title: RenderedContent, content: RenderedContent, format: String? = nil, sticky: Bool? = nil, excerpt: RenderedContent? = nil, status: String? = nil, password: String? = nil, comment_status: String? = nil, ping_status: String? = nil, categories: [Int], tags: [Int]) { + public init(id: Int, title: RenderedContent, content: RenderedContent, format: String? = nil, sticky: Bool? = nil, excerpt: RenderedContent? = nil, status: String? = nil, password: String? = nil, commentStatus: CommentStatus? = nil, ping_status: String? = nil, categories: [Int], tags: [Int]) { self.id = id self.title = title self.content = content @@ -158,14 +158,14 @@ public struct PostToUpdate: Encodable { self.excerpt = excerpt self.status = status self.password = password - self.comment_status = comment_status + self.commentStatus = commentStatus self.ping_status = ping_status self.categories = categories self.tags = tags } } -public struct RenderedContent: Codable { +public struct RenderedContent: Codable, Sendable { public let rendered: String public let protected: Bool diff --git a/Sources/WPSwift/Models/SimplePost.swift b/Sources/WPSwift/Models/SimplePost.swift index 6429781..0170b5b 100644 --- a/Sources/WPSwift/Models/SimplePost.swift +++ b/Sources/WPSwift/Models/SimplePost.swift @@ -7,7 +7,7 @@ import Foundation -public struct SimplePost: Decodable { +public struct SimplePost: Decodable, Sendable { public let id: Int public let title: String public let link: String diff --git a/Sources/WPSwift/Repositories/APIInfoRepository.swift b/Sources/WPSwift/Repositories/APIInfoRepository.swift index 1135949..8f13391 100644 --- a/Sources/WPSwift/Repositories/APIInfoRepository.swift +++ b/Sources/WPSwift/Repositories/APIInfoRepository.swift @@ -8,7 +8,7 @@ import Foundation import Resting -public struct APIInfoRepository { +public struct APIInfoRepository: Sendable { public init() {} public func getAPIInfo(route: String? = nil) async throws -> APIInfo { diff --git a/Sources/WPSwift/Repositories/CategoriesRepository.swift b/Sources/WPSwift/Repositories/CategoriesRepository.swift index 10c40e7..3abc71e 100644 --- a/Sources/WPSwift/Repositories/CategoriesRepository.swift +++ b/Sources/WPSwift/Repositories/CategoriesRepository.swift @@ -8,7 +8,7 @@ import Foundation import Resting -public struct CategoriesRepository { +public struct CategoriesRepository: Sendable { public init() {} public func getCategoriesClient(page: Int = 1, perPage: Int = 10, order: OrderType = .descending) throws -> WPClient { diff --git a/Sources/WPSwift/Repositories/PostsRepository.swift b/Sources/WPSwift/Repositories/PostsRepository.swift index ae5f727..eeb772c 100644 --- a/Sources/WPSwift/Repositories/PostsRepository.swift +++ b/Sources/WPSwift/Repositories/PostsRepository.swift @@ -8,7 +8,7 @@ import Foundation import Resting -public struct PostsRepository { +public struct PostsRepository: Sendable { public init() {} public func getPostsClient(page: Int = 1, perPage: Int = 10, order: OrderType = .descending, categories: [Int]? = nil, categoriesToExclude: [Int]? = nil, tags: [Int]? = nil, tagsToExclude: [Int]? = nil, include: [Int]? = nil) throws -> WPClient { diff --git a/Sources/WPSwift/WPSwift.swift b/Sources/WPSwift/WPSwift.swift index 1ea5799..955c9c1 100644 --- a/Sources/WPSwift/WPSwift.swift +++ b/Sources/WPSwift/WPSwift.swift @@ -2,7 +2,7 @@ // https://docs.swift.org/swift-book import Foundation -enum WPConfigurationError: LocalizedError { +enum WPConfigurationError: LocalizedError, Sendable { case wasNotSetup case route case namespace @@ -19,12 +19,12 @@ enum WPConfigurationError: LocalizedError { } } -struct WPConfiguration { +struct WPConfiguration: Sendable { let route: String let namespace: String } -public struct WPSwift { +public struct WPSwift: Sendable { static internal var configuration: WPConfiguration { get throws { guard let _configuration else { throw WPConfigurationError.wasNotSetup } @@ -33,7 +33,7 @@ public struct WPSwift { return _configuration } } - static private var _configuration: WPConfiguration? + nonisolated(unsafe) static private var _configuration: WPConfiguration? static let sessionConfiguration = URLSessionConfiguration.default static func resetConfiguration() { diff --git a/Tests/WPSwiftTests/APITests/APIClientTests.swift b/Tests/WPSwiftTests/APITests/APIClientTests.swift index 485bc3b..8d8f359 100644 --- a/Tests/WPSwiftTests/APITests/APIClientTests.swift +++ b/Tests/WPSwiftTests/APITests/APIClientTests.swift @@ -91,7 +91,7 @@ final class APIClientTests: XCTestCase { } .store(in: &cancellables) - waitForExpectations(timeout: 1) + wait(for: [expectation], timeout: 1) } func testAsyncWithFailure() async throws { @@ -146,7 +146,7 @@ final class APIClientTests: XCTestCase { } receiveValue: { _ in } .store(in: &cancellables) - waitForExpectations(timeout: 1) + wait(for: [expectation], timeout: 1) } // func testCombineWithEncodingFailure() throws { diff --git a/Tests/WPSwiftTests/Mocks/MockedURLProtocol.swift b/Tests/WPSwiftTests/Mocks/MockedURLProtocol.swift index 9c79725..53225cb 100644 --- a/Tests/WPSwiftTests/Mocks/MockedURLProtocol.swift +++ b/Tests/WPSwiftTests/Mocks/MockedURLProtocol.swift @@ -8,7 +8,7 @@ import Foundation class MockedURLProtocol: URLProtocol { - static var observer: ((URLRequest) throws -> (URLResponse?, Data?))? + nonisolated(unsafe) static var observer: ((URLRequest) throws -> (URLResponse?, Data?))? override class func canInit(with request: URLRequest) -> Bool { true diff --git a/Tests/WPSwiftTests/Mocks/SimplePost+Mock.swift b/Tests/WPSwiftTests/Mocks/SimplePost+Mock.swift index 3d1fc9a..f383257 100644 --- a/Tests/WPSwiftTests/Mocks/SimplePost+Mock.swift +++ b/Tests/WPSwiftTests/Mocks/SimplePost+Mock.swift @@ -36,8 +36,8 @@ extension Post { content: RenderedContent(rendered: "

Malesuada porta eu velit urna ante venenatis mus cum, facilisis ipsum rutrum molestie. Euismod diam netus id varius, varius adipiscing phasellus nisl nam. Natoque tellus pulvinar faucibus primis. Imperdiet nascetur nullam aliquam ut mus torquent litora aptent libero? Elementum nostra, lorem tincidunt cursus! Dui tristique dignissim felis curae;. Dis praesent pellentesque varius pharetra aenean elementum non amet tincidunt. Porttitor urna aptent mattis odio scelerisque augue convallis fringilla.

Rutrum conubia volutpat ad vulputate bibendum senectus magna molestie tincidunt placerat ultrices pulvinar. Vulputate semper sociis convallis eleifend et, ac aliquam sem massa diam. Metus at pharetra montes mi turpis arcu. Metus vestibulum feugiat massa sem aliquam odio blandit vivamus a lacinia nisi tellus. Urna venenatis sit ligula dis. In hac enim commodo vel euismod euismod. Quam condimentum vestibulum non orci. Lectus lacinia habitasse erat praesent. Nunc enim felis tempus hendrerit natoque viverra dui malesuada. Sapien dictum tortor nisl pulvinar, ut urna euismod velit. Ad convallis; rhoncus semper sapien urna. Vivamus magnis malesuada habitasse, platea platea.

Condimentum nam iaculis congue habitasse tortor cursus blandit commodo. Vestibulum euismod egestas risus. Ultricies blandit mattis montes ipsum orci accumsan rutrum aenean. Cras sociis, nibh lacus morbi. Justo convallis convallis sem primis ad proin. Gravida magna convallis ultrices torquent nec. Fames maecenas natoque parturient. Natoque ipsum fusce et fames, morbi ipsum. Lacinia aenean facilisi nascetur sociosqu, vitae faucibus. Maecenas tincidunt varius neque fermentum.

Magnis primis diam dui mauris dis habitant eleifend ligula at mollis. Nec parturient fermentum habitant torquent turpis laoreet dignissim nulla amet! Rhoncus nibh sapien lectus rhoncus. Suspendisse id hac conubia luctus diam nec curae;, proin tellus lacus ad est! Consequat proin mus erat duis leo a vivamus molestie massa. Varius, eros sit in pretium porttitor lacinia hendrerit habitasse vulputate? Nascetur potenti maecenas vestibulum nullam tellus lorem convallis augue ut.

Torquent hac augue donec tristique. Feugiat netus iaculis faucibus. Dis ullamcorper egestas id dictumst. Parturient rhoncus pharetra maecenas. Curabitur ad velit curae; integer. Lorem sodales et commodo nascetur ornare sociosqu aenean ligula at vestibulum. Vestibulum nam purus mollis varius sit nec mauris. Auctor tellus consectetur non et bibendum diam cubilia erat! Aptent vestibulum pretium mattis. Justo ac, nec integer. Turpis sem netus sed mus penatibus tempus. Potenti erat accumsan tempus mattis risus senectus curae;!

"), excerpt: RenderedContent(rendered: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."), author: 1, - featured_media: 5678, - comment_status: "open", + featuredMedia: 5678, + commentStatus: .open, categories: [1, 2], tags: [3, 4], link: "https://example.com/1234", @@ -74,8 +74,8 @@ extension Post { content: RenderedContent(rendered: "

Malesuada porta eu velit urna ante venenatis mus cum, facilisis ipsum rutrum molestie. Euismod diam netus id varius, varius adipiscing phasellus nisl nam. Natoque tellus pulvinar faucibus primis. Imperdiet nascetur nullam aliquam ut mus torquent litora aptent libero? Elementum nostra, lorem tincidunt cursus! Dui tristique dignissim felis curae;. Dis praesent pellentesque varius pharetra aenean elementum non amet tincidunt. Porttitor urna aptent mattis odio scelerisque augue convallis fringilla.

Rutrum conubia volutpat ad vulputate bibendum senectus magna molestie tincidunt placerat ultrices pulvinar. Vulputate semper sociis convallis eleifend et, ac aliquam sem massa diam. Metus at pharetra montes mi turpis arcu. Metus vestibulum feugiat massa sem aliquam odio blandit vivamus a lacinia nisi tellus. Urna venenatis sit ligula dis. In hac enim commodo vel euismod euismod. Quam condimentum vestibulum non orci. Lectus lacinia habitasse erat praesent. Nunc enim felis tempus hendrerit natoque viverra dui malesuada. Sapien dictum tortor nisl pulvinar, ut urna euismod velit. Ad convallis; rhoncus semper sapien urna. Vivamus magnis malesuada habitasse, platea platea.

Condimentum nam iaculis congue habitasse tortor cursus blandit commodo. Vestibulum euismod egestas risus. Ultricies blandit mattis montes ipsum orci accumsan rutrum aenean. Cras sociis, nibh lacus morbi. Justo convallis convallis sem primis ad proin. Gravida magna convallis ultrices torquent nec. Fames maecenas natoque parturient. Natoque ipsum fusce et fames, morbi ipsum. Lacinia aenean facilisi nascetur sociosqu, vitae faucibus. Maecenas tincidunt varius neque fermentum.

Magnis primis diam dui mauris dis habitant eleifend ligula at mollis. Nec parturient fermentum habitant torquent turpis laoreet dignissim nulla amet! Rhoncus nibh sapien lectus rhoncus. Suspendisse id hac conubia luctus diam nec curae;, proin tellus lacus ad est! Consequat proin mus erat duis leo a vivamus molestie massa. Varius, eros sit in pretium porttitor lacinia hendrerit habitasse vulputate? Nascetur potenti maecenas vestibulum nullam tellus lorem convallis augue ut.

Torquent hac augue donec tristique. Feugiat netus iaculis faucibus. Dis ullamcorper egestas id dictumst. Parturient rhoncus pharetra maecenas. Curabitur ad velit curae; integer. Lorem sodales et commodo nascetur ornare sociosqu aenean ligula at vestibulum. Vestibulum nam purus mollis varius sit nec mauris. Auctor tellus consectetur non et bibendum diam cubilia erat! Aptent vestibulum pretium mattis. Justo ac, nec integer. Turpis sem netus sed mus penatibus tempus. Potenti erat accumsan tempus mattis risus senectus curae;!

"), excerpt: RenderedContent(rendered: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."), author: 1, - featured_media: 5678, - comment_status: "open", + featuredMedia: 5678, + commentStatus: .open, categories: [1, 2], tags: [3, 4], link: "https://example.com/1234", @@ -117,7 +117,7 @@ extension PostToCreate { excerpt: RenderedContent(rendered: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."), status: "publish", password: "secretPassword", - comment_status: "open", + commentStatus: .open, ping_status: "closed", categories: [10, 20], tags: [50, 60] @@ -136,7 +136,7 @@ extension PostToUpdate { excerpt: RenderedContent(rendered: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."), status: "publish", password: "secretPassword", - comment_status: "open", + commentStatus: .open, ping_status: "closed", categories: [12, 22], tags: [52, 62] diff --git a/Tests/WPSwiftTests/RepositoryTests/PostsRepositoryTests.swift b/Tests/WPSwiftTests/RepositoryTests/PostsRepositoryTests.swift index e7a494f..58772f1 100644 --- a/Tests/WPSwiftTests/RepositoryTests/PostsRepositoryTests.swift +++ b/Tests/WPSwiftTests/RepositoryTests/PostsRepositoryTests.swift @@ -145,10 +145,10 @@ final class CategoriessRepositoryTests: XCTestCase { XCTAssertEqual(post.status, postFromData.status) XCTAssertEqual(post.title.rendered, postFromData.title.rendered) XCTAssertEqual(post.content.rendered, postFromData.content.rendered) - XCTAssertEqual(post.excerpt.rendered, postFromData.excerpt.rendered) + XCTAssertEqual(post.excerpt?.rendered, postFromData.excerpt?.rendered) XCTAssertEqual(post.author, postFromData.author) - XCTAssertEqual(post.featured_media, postFromData.featured_media) - XCTAssertEqual(post.comment_status, postFromData.comment_status) + XCTAssertEqual(post.featuredMedia, postFromData.featuredMedia) + XCTAssertEqual(post.commentStatus, postFromData.commentStatus) XCTAssertNotNil(post.categories) XCTAssertNotNil(postFromData.categories) @@ -156,10 +156,10 @@ final class CategoriessRepositoryTests: XCTestCase { XCTAssertNotNil(post.tags) XCTAssertNotNil(postFromData.tags) - XCTAssertNil(postFromData.embeddedContent.author) - XCTAssertNil(postFromData.embeddedContent.featuredMedia) - XCTAssertNil(post.embeddedContent.author) - XCTAssertNil(post.embeddedContent.featuredMedia) + XCTAssertNil(postFromData.embeddedContent?.author) + XCTAssertNil(postFromData.embeddedContent?.featuredMedia) + XCTAssertNil(post.embeddedContent?.author) + XCTAssertNil(post.embeddedContent?.featuredMedia) } func testCreatingPost() async throws { @@ -179,8 +179,8 @@ final class CategoriessRepositoryTests: XCTestCase { XCTAssertEqual(post.status, postFromData.status) XCTAssertEqual(post.title.rendered, postFromData.title.rendered) XCTAssertEqual(post.content.rendered, postFromData.content.rendered) - XCTAssertEqual(post.excerpt?.rendered, postFromData.excerpt.rendered) - XCTAssertEqual(post.comment_status, postFromData.comment_status) + XCTAssertEqual(post.excerpt?.rendered, postFromData.excerpt?.rendered) + XCTAssertEqual(post.commentStatus, postFromData.commentStatus) XCTAssertNotNil(post.categories) XCTAssertNotNil(postFromData.categories) @@ -188,8 +188,8 @@ final class CategoriessRepositoryTests: XCTestCase { XCTAssertNotNil(post.tags) XCTAssertNotNil(postFromData.tags) - XCTAssertNotNil(postFromData.embeddedContent.author) - XCTAssertNotNil(postFromData.embeddedContent.featuredMedia) + XCTAssertNotNil(postFromData.embeddedContent?.author) + XCTAssertNotNil(postFromData.embeddedContent?.featuredMedia) } func testCreatingPostWithBaseURL() async throws { @@ -209,8 +209,8 @@ final class CategoriessRepositoryTests: XCTestCase { XCTAssertEqual(post.status, postFromData.status) XCTAssertEqual(post.title.rendered, postFromData.title.rendered) XCTAssertEqual(post.content.rendered, postFromData.content.rendered) - XCTAssertEqual(post.excerpt?.rendered, postFromData.excerpt.rendered) - XCTAssertEqual(post.comment_status, postFromData.comment_status) + XCTAssertEqual(post.excerpt?.rendered, postFromData.excerpt?.rendered) + XCTAssertEqual(post.commentStatus, postFromData.commentStatus) XCTAssertNotNil(post.categories) XCTAssertNotNil(postFromData.categories) @@ -218,8 +218,8 @@ final class CategoriessRepositoryTests: XCTestCase { XCTAssertNotNil(post.tags) XCTAssertNotNil(postFromData.tags) - XCTAssertNotNil(postFromData.embeddedContent.author) - XCTAssertNotNil(postFromData.embeddedContent.featuredMedia) + XCTAssertNotNil(postFromData.embeddedContent?.author) + XCTAssertNotNil(postFromData.embeddedContent?.featuredMedia) } func testUpdatingPost() async throws { @@ -240,8 +240,8 @@ final class CategoriessRepositoryTests: XCTestCase { XCTAssertEqual(post.status, postFromData.status) XCTAssertEqual(post.title.rendered, postFromData.title.rendered) XCTAssertEqual(post.content.rendered, postFromData.content.rendered) - XCTAssertEqual(post.excerpt?.rendered, postFromData.excerpt.rendered) - XCTAssertEqual(post.comment_status, postFromData.comment_status) + XCTAssertEqual(post.excerpt?.rendered, postFromData.excerpt?.rendered) + XCTAssertEqual(post.commentStatus, postFromData.commentStatus) XCTAssertNotNil(post.categories) XCTAssertNotNil(postFromData.categories) @@ -249,8 +249,8 @@ final class CategoriessRepositoryTests: XCTestCase { XCTAssertNotNil(post.tags) XCTAssertNotNil(postFromData.tags) - XCTAssertNotNil(postFromData.embeddedContent.author) - XCTAssertNotNil(postFromData.embeddedContent.featuredMedia) + XCTAssertNotNil(postFromData.embeddedContent?.author) + XCTAssertNotNil(postFromData.embeddedContent?.featuredMedia) } func testUpdatingPostWithBaseURL() async throws { @@ -271,8 +271,8 @@ final class CategoriessRepositoryTests: XCTestCase { XCTAssertEqual(post.status, postFromData.status) XCTAssertEqual(post.title.rendered, postFromData.title.rendered) XCTAssertEqual(post.content.rendered, postFromData.content.rendered) - XCTAssertEqual(post.excerpt?.rendered, postFromData.excerpt.rendered) - XCTAssertEqual(post.comment_status, postFromData.comment_status) + XCTAssertEqual(post.excerpt?.rendered, postFromData.excerpt?.rendered) + XCTAssertEqual(post.commentStatus, postFromData.commentStatus) XCTAssertNotNil(post.categories) XCTAssertNotNil(postFromData.categories) @@ -280,8 +280,8 @@ final class CategoriessRepositoryTests: XCTestCase { XCTAssertNotNil(post.tags) XCTAssertNotNil(postFromData.tags) - XCTAssertNotNil(postFromData.embeddedContent.author) - XCTAssertNotNil(postFromData.embeddedContent.featuredMedia) + XCTAssertNotNil(postFromData.embeddedContent?.author) + XCTAssertNotNil(postFromData.embeddedContent?.featuredMedia) } private func test(post: Post, with postFromData: Post) { @@ -292,10 +292,10 @@ final class CategoriessRepositoryTests: XCTestCase { XCTAssertEqual(post.status, postFromData.status) XCTAssertEqual(post.title.rendered, postFromData.title.rendered) XCTAssertEqual(post.content.rendered, postFromData.content.rendered) - XCTAssertEqual(post.excerpt.rendered, postFromData.excerpt.rendered) + XCTAssertEqual(post.excerpt?.rendered, postFromData.excerpt?.rendered) XCTAssertEqual(post.author, postFromData.author) - XCTAssertEqual(post.featured_media, postFromData.featured_media) - XCTAssertEqual(post.comment_status, postFromData.comment_status) + XCTAssertEqual(post.featuredMedia, postFromData.featuredMedia) + XCTAssertEqual(post.commentStatus, postFromData.commentStatus) XCTAssertNotNil(post.categories) XCTAssertNotNil(postFromData.categories) @@ -303,16 +303,16 @@ final class CategoriessRepositoryTests: XCTestCase { XCTAssertNotNil(post.tags) XCTAssertNotNil(postFromData.tags) - let authorFromData = postFromData.embeddedContent.author! - let author = post.embeddedContent.author! + let authorFromData = postFromData.embeddedContent!.author! + let author = post.embeddedContent!.author! // Assertions for author XCTAssertEqual(author.id, authorFromData.id) XCTAssertEqual(author.name, authorFromData.name) XCTAssertEqual(author.description, authorFromData.description) - let featuredMediaFromData = postFromData.embeddedContent.featuredMedia! - let featuredMedia = post.embeddedContent.featuredMedia! + let featuredMediaFromData = postFromData.embeddedContent!.featuredMedia! + let featuredMedia = post.embeddedContent!.featuredMedia! // Assertions for featured media XCTAssertEqual(featuredMedia.id, featuredMediaFromData.id)