Skip to content

Commit

Permalink
Merge pull request Carthage#2121 from Carthage/improve-giturl-normali…
Browse files Browse the repository at this point in the history
…zedurlstring-tests

[GitURL] Improve `normalizedURLString` tests to be more granular
  • Loading branch information
mdiep committed Aug 16, 2017
2 parents 66592a9 + 80fcebf commit 039a70d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Source/CarthageKit/GitURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public struct GitURL {
/// A normalized URL string, without protocol, authentication, or port
/// information. This is mostly useful for comparison, and not for any
/// actual Git operations.
fileprivate var normalizedURLString: String {
internal var normalizedURLString: String {
let parsedURL: URL? = URL(string: urlString)

if let parsedURL = parsedURL, let host = parsedURL.host {
Expand Down
17 changes: 12 additions & 5 deletions Tests/CarthageKitTests/GitURLSpec.swift
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
import CarthageKit
import Foundation
import Nimble
import Quick

@testable import CarthageKit

class GitURLSpec: QuickSpec {
override func spec() {
describe("GitURL") {
describe("normalizedURLString") {
it("should parse normal URL") {
expect(GitURL("https://github.com/antitypical/Result.git")) == GitURL("https://user:password@github.com:443/antitypical/Result")
let expected = "github.com/antitypical/Result"
expect(GitURL("https://github.com/antitypical/Result.git").normalizedURLString) == expected
expect(GitURL("https://user:password@github.com:443/antitypical/Result").normalizedURLString) == expected
}

it("should parse local path") {
expect(GitURL("/path/to/git/repo.git")) == GitURL("/path/to/git/repo")
it("should parse local absolute path") {
let expected = "/path/to/git/repo"
expect(GitURL("/path/to/git/repo.git").normalizedURLString) == expected
expect(GitURL("/path/to/git/repo").normalizedURLString) == expected
}

it("should parse scp syntax") {
expect(GitURL("git@github.com:antitypical/Result.git")) == GitURL("github.com:antitypical/Result")
let expected = "github.com/antitypical/Result"
expect(GitURL("git@github.com:antitypical/Result.git").normalizedURLString) == expected
expect(GitURL("github.com:antitypical/Result").normalizedURLString) == expected
}
}
}
Expand Down

0 comments on commit 039a70d

Please sign in to comment.