Skip to content

Commit

Permalink
update: use staticString extension of URL, fix more lint-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
devahmedshendy committed Sep 6, 2023
1 parent 2876e19 commit 65391c5
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal final class FileManagerExtensionTests: XCTestCase {
XCTAssertThrowsError(
try FileManager.createDirectory(
withName: "test",
in: try .make(string: "/fake/path")
in: URL("/fake/path")
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extension AssetImport {
internal static func makeAssetImportForAttachmentA() throws -> AssetImport {
try .make(
forPost: .attachmentA(),
sourceURL: try .make(string: "http://leogdion.name")
sourceURL: URL("http://leogdion.name")
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extension WordPressPost {
postID: 1,
title: "2018 - My Year in Review",
contentEncoded: .myYearInReviewContent,
link: try .make(string: "https://leogdion.name/2019/01/14/2018-review/"),
link: URL("https://leogdion.name/2019/01/14/2018-review/"),
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",
categories: tags ?? []
Expand All @@ -22,7 +22,7 @@ extension WordPressPost {
postID: 2,
title: "Are We There Yet?",
contentEncoded: .areWeThereYetContent,
link: .make(string: "https://leogdion.name/2018/12/13/are-we-there-yet/"),
link: URL("https://leogdion.name/2018/12/13/are-we-there-yet/"),
postName: "are-we-there-yet",
categories: tags ?? []
)
Expand All @@ -33,7 +33,7 @@ extension WordPressPost {
postID: 3,
title: "From Goals to Actions 2018",
contentEncoded: .fromGoalsToActionsContent,
link: .make(string: "https://leogdion.name/2018/01/08/from-goals-to-actions-2018/diagram-for-goals/"),
link: URL("https://leogdion.name/2018/01/08/from-goals-to-actions-2018/diagram-for-goals/"),
postName: "from-goals-to-actions-2018",
categories: tags ?? []
)
Expand All @@ -44,7 +44,7 @@ extension WordPressPost {
postID: 4,
title: "Podcasting - Getting Started - Whys and Hows",
contentEncoded: .podcastingContent,
link: .make(string: "https://leogdion.name/2019/06/13/podcasting-getting-started-content-recording-audience/"),
link: URL("https://leogdion.name/2019/06/13/podcasting-getting-started-content-recording-audience/"),
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",
categories: tags ?? []
Expand All @@ -58,7 +58,7 @@ extension WordPressPost {
postID: 4,
title: "Productivity Apps for Developers (and Everyone Else)",
contentEncoded: .productivityContent,
link: .make(string: "https://leogdion.name/2019/08/01/productivity-apps-for-developers-and-everyone/"),
link: URL("https://leogdion.name/2019/08/01/productivity-apps-for-developers-and-everyone/"),
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",
categories: tags ?? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ extension WordPressSite {
internal static func leogdion() throws -> WordPressSite {
try .make(
title: "Leo G Dion",
link: try .make(string: "https://leogdion.name"),
link: URL("https://leogdion.name"),
description: "Personal Blog",
categories: [
.init(termID: 1, niceName: "uncategorized", parent: "", name: "Uncategorized")
],
tags: leogdionTags(),
baseSiteURL: URL(string: "https://leogdion.name"),
baseBlogURL: URL(string: "https://leogdion.name"),
baseSiteURL: URL("https://leogdion.name"),
baseBlogURL: URL("https://leogdion.name"),
posts: try leogdionPosts()
)
}
Expand Down

This file was deleted.

16 changes: 16 additions & 0 deletions Tests/ContributeWordPressTests/Helpers/Extension/URL.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Foundation

extension URL {
internal init(_ staticString: StaticString) {
guard let url = URL(string: .init(describing: staticString)) else {
fatalError("Invalid URL String")
}
self = url
}
}

extension URL {
internal static func makeRootPublishSiteURL() -> URL {
.temporaryDirURL.appendingPathComponent(UUID().uuidString)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ internal final class AssetDownloaderTests: XCTestCase {
forPost: try .myYearInReviewPost(),
sourceURL: .temporaryResourcesPathURL,
assetRoot: "/media/wp-assets",
resourcesPathURL: try .make(
string: "https://leogdion.name/wp-content/uploads/2019/06/-unsplash-701.jpeg"
resourcesPathURL: URL(
"https://leogdion.name/wp-content/uploads/2019/06/-unsplash-701.jpeg"
),
importPathURL: nil
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import XCTest
internal final class AssetImportWordPressTests: XCTestCase {
internal func testExtractAssetImportFromPostWithAssets() throws {
let site: WordPressSite = try .make(
link: try .make(string: "https://leogdion.name"),
link: URL("https://leogdion.name"),
posts: [.myYearInReviewPost()]
)

Expand All @@ -25,7 +25,7 @@ internal final class AssetImportWordPressTests: XCTestCase {

internal func testExtractAssetImportFromPostWithoutAssets() throws {
let site: WordPressSite = try .make(
link: try .make(string: "https://leogdion.name"),
link: URL("https://leogdion.name"),
posts: [.make(postID: 00, title: "fake", contentEncoded: "")]
)

Expand Down
4 changes: 2 additions & 2 deletions Tests/ContributeWordPressTests/URLExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal final class URLExtensionTests: XCTestCase {
let expectedString = "banner.jpg"
let filename = expectedString + ".jpg"

let url: URL = try .make(string: "https://leogdion.name/wp-content/uploads/2018/12/")
let url = URL("https://leogdion.name/wp-content/uploads/2018/12/")
.appendingPathComponent(filename)

let actualString = url.lastPathComponentWithoutExtension()
Expand All @@ -30,7 +30,7 @@ internal final class URLExtensionTests: XCTestCase {
}

internal func testRelativePathFromBaseNotFileURLShouldBeNil() throws {
let projectPathURL: URL = try .make(string: "http://www.google.com")
let projectPathURL = URL("http://www.google.com")

let expectedRelativePath = PublishDefaults.resourcesDirectoryName

Expand Down

0 comments on commit 65391c5

Please sign in to comment.