-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Swift Package Manager 5.6
- Loading branch information
Showing
2 changed files
with
115 additions
and
29 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
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,8 +10,7 @@ import XCTest | |
@testable import LicensePlistCore | ||
|
||
class SwiftPackageManagerTests: XCTestCase { | ||
|
||
func testDecoding() throws { | ||
func testDecodingV1() throws { | ||
let jsonString = """ | ||
{ | ||
"package": "APIKit", | ||
|
@@ -25,15 +24,15 @@ class SwiftPackageManagerTests: XCTestCase { | |
""" | ||
|
||
let data = try XCTUnwrap(jsonString.data(using: .utf8)) | ||
let package = try JSONDecoder().decode(SwiftPackage.self, from: data) | ||
let package = try JSONDecoder().decode(SwiftPackageV1.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 testDecodingOfURLWithDots() throws { | ||
func testDecodingOfURLWithDotsV1() throws { | ||
let jsonString = """ | ||
{ | ||
"package": "R.swift.Library", | ||
|
@@ -47,15 +46,15 @@ class SwiftPackageManagerTests: XCTestCase { | |
""" | ||
|
||
let data = try XCTUnwrap(jsonString.data(using: .utf8)) | ||
let package = try JSONDecoder().decode(SwiftPackage.self, from: data) | ||
let package = try JSONDecoder().decode(SwiftPackageV1.self, from: data) | ||
|
||
XCTAssertEqual(package.package, "R.swift.Library") | ||
XCTAssertEqual(package.repositoryURL, "https://github.com/mac-cain13/R.swift.Library") | ||
XCTAssertEqual(package.state.revision, "3365947d725398694d6ed49f2e6622f05ca3fc0f") | ||
XCTAssertEqual(package.state.version, nil) | ||
XCTAssertNil(package.state.version) | ||
} | ||
|
||
func testDecodingOptionalVersion() throws { | ||
func testDecodingOptionalVersionV1() throws { | ||
let jsonString = """ | ||
{ | ||
"package": "APIKit", | ||
|
@@ -69,74 +68,126 @@ class SwiftPackageManagerTests: XCTestCase { | |
""" | ||
|
||
let data = try XCTUnwrap(jsonString.data(using: .utf8)) | ||
let package = try JSONDecoder().decode(SwiftPackage.self, from: data) | ||
let package = try JSONDecoder().decode(SwiftPackageV1.self, from: data) | ||
|
||
XCTAssertEqual(package.package, "APIKit") | ||
XCTAssertEqual(package.repositoryURL, "https://github.com/ishkawa/APIKit.git") | ||
XCTAssertEqual(package.state.revision, "86d51ecee0bc0ebdb53fb69b11a24169a69097ba") | ||
XCTAssertEqual(package.state.branch, "master") | ||
XCTAssertEqual(package.state.version, nil) | ||
XCTAssertNil(package.state.version) | ||
} | ||
|
||
func testDecodingWithVersionV2() throws { | ||
let jsonString = """ | ||
{ | ||
"identity" : "APIKit", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/ishkawa/APIKit.git", | ||
"state" : { | ||
"revision" : "86d51ecee0bc0ebdb53fb69b11a24169a69097ba", | ||
"version" : "4.1.0" | ||
} | ||
} | ||
""" | ||
|
||
let data = try XCTUnwrap(jsonString.data(using: .utf8)) | ||
let package = try JSONDecoder().decode(SwiftPackageV2.self, from: data) | ||
|
||
XCTAssertEqual(package.identity, "APIKit") | ||
XCTAssertEqual(package.location, "https://github.com/ishkawa/APIKit.git") | ||
XCTAssertEqual(package.state.revision, "86d51ecee0bc0ebdb53fb69b11a24169a69097ba") | ||
XCTAssertNil(package.state.branch) | ||
XCTAssertEqual(package.state.version, "4.1.0") | ||
} | ||
|
||
func testDecodingWithBranchV2() throws { | ||
let jsonString = """ | ||
{ | ||
"identity" : "APIKit", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/ishkawa/APIKit.git", | ||
"state" : { | ||
"branch" : "master", | ||
"revision" : "86d51ecee0bc0ebdb53fb69b11a24169a69097ba" | ||
} | ||
} | ||
""" | ||
|
||
let data = try XCTUnwrap(jsonString.data(using: .utf8)) | ||
let package = try JSONDecoder().decode(SwiftPackageV2.self, from: data) | ||
|
||
XCTAssertEqual(package.identity, "APIKit") | ||
XCTAssertEqual(package.location, "https://github.com/ishkawa/APIKit.git") | ||
XCTAssertEqual(package.state.revision, "86d51ecee0bc0ebdb53fb69b11a24169a69097ba") | ||
XCTAssertEqual(package.state.branch, "master") | ||
XCTAssertNil(package.state.version) | ||
} | ||
|
||
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")) | ||
revision: "e5b50ad7b2e91eeb828393e89b03577b16be7db9", | ||
version: "0.8.0") | ||
let result = package.toGitHub(renames: [:]) | ||
XCTAssertEqual(result, GitHub(name: "Commander", nameSpecified: "Commander", owner: "kylef", version: "0.8.0")) | ||
} | ||
|
||
func testConvertToGithubNameWithDots() { | ||
let package = SwiftPackage(package: "R.swift.Library", | ||
repositoryURL: "https://github.com/mac-cain13/R.swift.Library", | ||
state: SwiftPackage.State(branch: nil, revision: "3365947d725398694d6ed49f2e6622f05ca3fc0f", version: nil)) | ||
revision: "3365947d725398694d6ed49f2e6622f05ca3fc0f", | ||
version: nil) | ||
let result = package.toGitHub(renames: [:]) | ||
XCTAssertEqual(result, GitHub(name: "R.swift.Library", nameSpecified: "R.swift.Library", owner: "mac-cain13", version: nil)) | ||
} | ||
|
||
func testConvertToGithubSSH() { | ||
let package = SwiftPackage(package: "LicensePlist", | ||
repositoryURL: "[email protected]:mono0926/LicensePlist.git", | ||
state: SwiftPackage.State(branch: nil, revision: "3365947d725398694d6ed49f2e6622f05ca3fc0e", version: nil)) | ||
revision: "3365947d725398694d6ed49f2e6622f05ca3fc0e", | ||
version: nil) | ||
let result = package.toGitHub(renames: [:]) | ||
XCTAssertEqual(result, GitHub(name: "LicensePlist", nameSpecified: "LicensePlist", owner: "mono0926", version: nil)) | ||
} | ||
|
||
func testConvertToGithubPackageName() { | ||
let package = SwiftPackage(package: "IterableSDK", | ||
repositoryURL: "https://github.com/Iterable/swift-sdk", | ||
state: SwiftPackage.State(branch: nil, revision: "3365947d725398694d6ed49f2e6622f05ca3fc0e", version: nil)) | ||
revision: "3365947d725398694d6ed49f2e6622f05ca3fc0e", | ||
version: nil) | ||
let result = package.toGitHub(renames: [:]) | ||
XCTAssertEqual(result, GitHub(name: "swift-sdk", nameSpecified: "IterableSDK", owner: "Iterable", version: nil)) | ||
} | ||
|
||
func testConvertToGithubRenames() { | ||
let package = SwiftPackage(package: "IterableSDK", | ||
repositoryURL: "https://github.com/Iterable/swift-sdk", | ||
state: SwiftPackage.State(branch: nil, revision: "3365947d725398694d6ed49f2e6622f05ca3fc0e", version: nil)) | ||
revision: "3365947d725398694d6ed49f2e6622f05ca3fc0e", | ||
version: nil) | ||
let result = package.toGitHub(renames: ["swift-sdk": "NAME"]) | ||
XCTAssertEqual(result, GitHub(name: "swift-sdk", nameSpecified: "NAME", owner: "Iterable", version: nil)) | ||
} | ||
|
||
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")) | ||
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 package = SwiftPackage(package: "Google", repositoryURL: "http://www.google.com", 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")) | ||
revision: "", | ||
version: "0.0.0") | ||
let result = package.toGitHub(renames: [:]) | ||
XCTAssertNil(result) | ||
} | ||
|
@@ -153,11 +204,13 @@ class SwiftPackageManagerTests: XCTestCase { | |
let packageFirst = try XCTUnwrap(packages.first) | ||
XCTAssertEqual(packageFirst, SwiftPackage(package: "APIKit", | ||
repositoryURL: "https://github.com/ishkawa/APIKit.git", | ||
state: SwiftPackage.State(branch: nil, revision: "c8f5320d84c4c34c0fd965da3c7957819a1ccdd4", version: "5.2.0"))) | ||
revision: "c8f5320d84c4c34c0fd965da3c7957819a1ccdd4", | ||
version: "5.2.0")) | ||
let packageLast = try XCTUnwrap(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"))) | ||
revision: "287f5cab7da0d92eb947b5fd8151b203ae04a9a3", | ||
version: "3.4.4")) | ||
|
||
} | ||
} |