Skip to content

Commit

Permalink
Add tests to verify bug with PackageReference.name property and resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
liamnichols committed Dec 24, 2019
1 parent f6e3a60 commit 9f4e2a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/MintKit/PackageReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class PackageReference {
}

public var name: String {
return repo.components(separatedBy: "/").last!.components(separatedBy: ".").first!
return repo.components(separatedBy: "/").last!.replacingOccurrences(of: ".git", with: "")
}

public var gitPath: String {
Expand Down
23 changes: 23 additions & 0 deletions Tests/MintTests/PackageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,29 @@ class PackageTests: XCTestCase {
}
}

func testPackageNames() {

let urls: [String: String] = [
"yonaskolb/mint": "mint",
"github.com/yonaskolb/mint": "mint",
"https://github.com/yonaskolb/mint": "mint",
"https://github.com/yonaskolb/mint.git": "mint",
"mycustomdomain.com/package": "package",
"mycustomdomain.com/package.git": "package",
"https://mycustomdomain.com/package": "package",
"https://mycustomdomain.com/package.git": "package",
"git@github.com:yonaskolb/Mint.git": "Mint",
"mac-cain13/R.swift": "R.swift",
"github.com/mac-cain13/R.swift": "R.swift",
"https://github.com/mac-cain13/R.swift.git": "R.swift",
"git@github.com:mac-cain13/R.swift.git": "R.swift",
]

for (url, expected) in urls {
XCTAssertEqual(PackageReference(repo: url).name, expected)
}
}

func testPackageReferenceInfo() {

XCTAssertEqual(PackageReference(package: "yonaskolb/mint"), PackageReference(repo: "yonaskolb/mint"))
Expand Down

0 comments on commit 9f4e2a6

Please sign in to comment.