diff --git a/Sources/ContributeWordPress/Images/AssetImport.swift b/Sources/ContributeWordPress/Images/AssetImport.swift index d7ac61e8..4cec0b67 100644 --- a/Sources/ContributeWordPress/Images/AssetImport.swift +++ b/Sources/ContributeWordPress/Images/AssetImport.swift @@ -32,8 +32,8 @@ public struct AssetImport: Hashable { featuredPath: String, parentID: Int ) { - fromURL = importFromURL - atURL = importAtURL + self.fromURL = importFromURL + self.atURL = importAtURL self.featuredPath = featuredPath self.parentID = parentID } diff --git a/Tests/ContributeWordPressTests/Helpers/Extension/FakeData/WordPressPost+Fake.swift b/Tests/ContributeWordPressTests/Helpers/Extension/FakeData/WordPressPost+Fake.swift index 29197a3d..f7271c17 100644 --- a/Tests/ContributeWordPressTests/Helpers/Extension/FakeData/WordPressPost+Fake.swift +++ b/Tests/ContributeWordPressTests/Helpers/Extension/FakeData/WordPressPost+Fake.swift @@ -13,7 +13,8 @@ extension WordPressPost { description: "My main goal this year was to produce more content online and less time on local events and gatherings. Unfortunately, that wasn't the case.", postName: "2018-review", contentEncoded: .myYearInReviewContent, - categories: tags ?? [] + categories: tags ?? [], + postID: 1 ) } @@ -23,7 +24,8 @@ extension WordPressPost { link: URL(string: "https://leogdion.name/2018/12/13/are-we-there-yet/")!, postName: "are-we-there-yet", contentEncoded: .areWeThereYetContent, - categories: tags ?? [] + categories: tags ?? [], + postID: 2 ) } @@ -33,7 +35,8 @@ extension WordPressPost { link: URL(string: "https://leogdion.name/2018/01/08/from-goals-to-actions-2018/diagram-for-goals/")!, postName: "from-goals-to-actions-2018", contentEncoded: .fromGoalsToActionsContent, - categories: tags ?? [] + categories: tags ?? [], + postID: 3 ) } @@ -44,7 +47,8 @@ extension WordPressPost { description: "Generally speaking, podcasting gives specific audiences an in-depth specialized analysis without the need to appeal to the general audience.", postName: "podcasting-getting-started-content-recording-audience", contentEncoded: .podcastingContent, - categories: tags ?? [] + categories: tags ?? [], + postID: 4 ) } @@ -57,22 +61,38 @@ extension WordPressPost { description: "It's important to keep a set of great productivity app which help me optimize rather than distract. Here's a list of productivity apps and services to help you.", postName: "productivity-apps-for-developers-and-everyone", contentEncoded: .productivityContent, - categories: tags ?? [] + categories: tags ?? [], + postID: 4 ) } } extension WordPressPost { - internal static func attachmentA() throws -> WordPressPost { - try .make(title: "\(#function)", type: "attachment", contentEncoded: "") + internal static func attachmentA(postID: Int = 1) throws -> WordPressPost { + try .make( + title: "\(#function)", + type: "attachment", + contentEncoded: "", + postID: postID + ) } - internal static func attachmentB() throws -> WordPressPost { - try .make(title: "\(#function)", type: "attachment", contentEncoded: "") + internal static func attachmentB(postID: Int = 1) throws -> WordPressPost { + try .make( + title: "\(#function)", + type: "attachment", + contentEncoded: "", + postID: postID + ) } - internal static func attachmentC() throws -> WordPressPost { - try .make(title: "\(#function)", type: "attachment", contentEncoded: "") + internal static func attachmentC(postID: Int = 1) throws -> WordPressPost { + try .make( + title: "\(#function)", + type: "attachment", + contentEncoded: "", + postID: postID + ) } } diff --git a/Tests/ContributeWordPressTests/Helpers/Extension/Make/RSSItem+Make.swift b/Tests/ContributeWordPressTests/Helpers/Extension/Make/RSSItem+Make.swift index 9b4a18f4..6bf8070b 100644 --- a/Tests/ContributeWordPressTests/Helpers/Extension/Make/RSSItem+Make.swift +++ b/Tests/ContributeWordPressTests/Helpers/Extension/Make/RSSItem+Make.swift @@ -17,6 +17,7 @@ extension RSSItem { postDate: Date?, categories: [RSSItemCategory], creators: [String], + postID: Int, status: String, attachmentURL: URL? ) -> RSSItem { @@ -46,7 +47,7 @@ extension RSSItem { wpMenuOrder: .bitWidth, wpIsSticky: .bitWidth, wpPostPassword: .init(), - wpPostID: 10, + wpPostID: postID, wpPostDate: postDate, wpPostDateGMT: .distantFuture, wpModifiedDate: .distantFuture, diff --git a/Tests/ContributeWordPressTests/Helpers/Extension/Make/WordPressPost+Make.swift b/Tests/ContributeWordPressTests/Helpers/Extension/Make/WordPressPost+Make.swift index 868ea025..37e03560 100644 --- a/Tests/ContributeWordPressTests/Helpers/Extension/Make/WordPressPost+Make.swift +++ b/Tests/ContributeWordPressTests/Helpers/Extension/Make/WordPressPost+Make.swift @@ -14,6 +14,7 @@ extension WordPressPost { contentEncoded: String? = nil, categories: [RSSItemCategory] = [.Podcasting, .Productivity], creators: [String] = ["Leo"], + postID: Int, status: String = "publish", attachmentURL: URL? = nil ) throws -> WordPressPost { @@ -30,6 +31,7 @@ extension WordPressPost { postDate: postDate, categories: categories, creators: creators, + postID: postID, status: status, attachmentURL: attachmentURL ) diff --git a/Tests/ContributeWordPressTests/Images/AssetImportWordPressTests.swift b/Tests/ContributeWordPressTests/Images/AssetImportWordPressTests.swift index 48a815f4..1fcf2711 100644 --- a/Tests/ContributeWordPressTests/Images/AssetImportWordPressTests.swift +++ b/Tests/ContributeWordPressTests/Images/AssetImportWordPressTests.swift @@ -6,24 +6,29 @@ internal final class AssetImportWordPressTests: XCTestCase { let site: WordPressSite = try .make( link: try .make(string: "https://leogdion.name"), posts: [ - .productivityAppsPost() + .myYearInReviewPost() ] ) let rootPublishSiteURL: URL = .temporaryDirURL + let expoertingDirectoryURL: URL = rootPublishSiteURL + .appendingPathComponent("WordPress/exports") + let assetImports = AssetImport.extractAssetImports( from: site, using: Settings( rootPublishSiteURL: rootPublishSiteURL, - exportsDirectoryURL: rootPublishSiteURL - .appendingPathComponent("WordPress/exports") + exportsDirectoryURL: expoertingDirectoryURL ) ) - // TODO: Write the actual tests + // TODO: Only this final tests needs to be finished for assetImport in assetImports { - print(assetImport.fromURL) - print(assetImport.atURL) +// XCTAssertEqual(assetImport.parentID, site.???) + + print("fromURL: " + assetImport.fromURL.absoluteString) + print("fromURL: " + assetImport.fromURL.absoluteString) + print("parentID: \(assetImport.parentID)") } } }