-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
42 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ included: | |
- Sources | ||
- Tests | ||
|
||
line_length: 180 | ||
line_length: 190 | ||
nesting: | ||
type_level: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import XCTest | |
@testable import LicensePlistCore | ||
|
||
class SwiftPackageManagerTests: XCTestCase { | ||
|
||
func testDecoding() { | ||
let jsonString = """ | ||
{ | ||
|
@@ -23,53 +23,64 @@ class SwiftPackageManagerTests: XCTestCase { | |
} | ||
} | ||
""" | ||
|
||
let data = jsonString.data(using: .utf8)! | ||
let package = try! JSONDecoder().decode(SwiftPackage.self, from: data) | ||
|
||
XCTAssertEqual(package.package, "APIKit") | ||
XCTAssertEqual(package.repositoryURL, "https://github.com/ishkawa/APIKit.git") | ||
XCTAssertEqual(package.state.revision, "86d51ecee0bc0ebdb53fb69b11a24169a69097ba") | ||
XCTAssertEqual(package.state.version, "4.1.0") | ||
} | ||
|
||
func testConvertToGithub() { | ||
let package = SwiftPackage(package: "Commander", repositoryURL: "https://github.com/kylef/Commander.git", state: SwiftPackage.State(branch: nil, revision: "e5b50ad7b2e91eeb828393e89b03577b16be7db9", version: "0.8.0")) | ||
let package = SwiftPackage(package: "Commander", | ||
repositoryURL: "https://github.com/kylef/Commander.git", | ||
state: SwiftPackage.State(branch: nil, revision: "e5b50ad7b2e91eeb828393e89b03577b16be7db9", version: "0.8.0")) | ||
let result = package.toGitHub(renames: [:]) | ||
XCTAssertEqual(result, GitHub(name: "Commander", nameSpecified: nil, owner: "kylef", version: "0.8.0")) | ||
} | ||
|
||
func testRename() { | ||
let package = SwiftPackage(package: "Commander", repositoryURL: "https://github.com/kylef/Commander.git", state: SwiftPackage.State(branch: nil, revision: "e5b50ad7b2e91eeb828393e89b03577b16be7db9", version: "0.8.0")) | ||
let package = SwiftPackage(package: "Commander", | ||
repositoryURL: "https://github.com/kylef/Commander.git", | ||
state: SwiftPackage.State(branch: nil, | ||
revision: "e5b50ad7b2e91eeb828393e89b03577b16be7db9", version: "0.8.0")) | ||
let result = package.toGitHub(renames: ["Commander": "RenamedCommander"]) | ||
XCTAssertEqual(result, GitHub(name: "Commander", nameSpecified: "RenamedCommander", owner: "kylef", version: "0.8.0")) | ||
} | ||
|
||
func testInvalidURL() { | ||
let package = SwiftPackage(package: "Google", repositoryURL: "http://www.google.com", state: SwiftPackage.State(branch: nil, revision: "", version: "0.0.0")) | ||
let result = package.toGitHub(renames: [:]) | ||
XCTAssertNil(result) | ||
} | ||
|
||
func testNonGithub() { | ||
let package = SwiftPackage(package: "Bitbucket", repositoryURL: "https://[email protected]/mbuchetics/adventofcode2018.git", state: SwiftPackage.State(branch: nil, revision: "", version: "0.0.0")) | ||
let package = SwiftPackage(package: "Bitbucket", | ||
repositoryURL: "https://[email protected]/mbuchetics/adventofcode2018.git", | ||
state: SwiftPackage.State(branch: nil, revision: "", version: "0.0.0")) | ||
let result = package.toGitHub(renames: [:]) | ||
XCTAssertNil(result) | ||
} | ||
|
||
func testParse() { | ||
let path = "https://raw.githubusercontent.com/mono0926/LicensePlist/master/Package.resolved" | ||
//let path = "https://raw.githubusercontent.com/mono0926/LicensePlist/master/Tests/LicensePlistTests/Resources/Package.resolved" | ||
let content = try! String(contentsOf: URL(string: path)!) | ||
let packages = SwiftPackage.loadPackages(content) | ||
|
||
XCTAssertFalse(packages.isEmpty) | ||
XCTAssertEqual(packages.count, 8) | ||
|
||
let packageFirst = packages.first! | ||
XCTAssertEqual(packageFirst, SwiftPackage(package: "APIKit", repositoryURL: "https://github.com/ishkawa/APIKit.git", state: SwiftPackage.State(branch: nil, revision: "86d51ecee0bc0ebdb53fb69b11a24169a69097ba", version: "4.1.0"))) | ||
XCTAssertEqual(packageFirst, SwiftPackage(package: "APIKit", | ||
repositoryURL: "https://github.com/ishkawa/APIKit.git", | ||
state: SwiftPackage.State(branch: nil, revision: "86d51ecee0bc0ebdb53fb69b11a24169a69097ba", version: "4.1.0"))) | ||
let packageLast = packages.last! | ||
XCTAssertEqual(packageLast, SwiftPackage(package: "Yaml", repositoryURL: "https://github.com/behrang/YamlSwift.git", state: SwiftPackage.State(branch: nil, revision: "287f5cab7da0d92eb947b5fd8151b203ae04a9a3", version: "3.4.4"))) | ||
|
||
XCTAssertEqual(packageLast, SwiftPackage(package: "Yaml", | ||
repositoryURL: "https://github.com/behrang/YamlSwift.git", | ||
state: SwiftPackage.State(branch: nil, revision: "287f5cab7da0d92eb947b5fd8151b203ae04a9a3", version: "3.4.4"))) | ||
|
||
} | ||
} |