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 b7721f8 commit aaa3c86
Show file tree
Hide file tree
Showing 2 changed files with 21 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
20 changes: 20 additions & 0 deletions Tests/MintTests/PackageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ 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",
]

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 aaa3c86

Please sign in to comment.