-
Notifications
You must be signed in to change notification settings - Fork 163
Support a relative path for the options to "link to source" for the --checkout-path CLI option #490 #929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Support a relative path for the options to "link to source" for the --checkout-path CLI option #490 #929
Changes from 1 commit
be84a97
f08135e
923e328
153cd70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Updated testSourceRepositoryAllArgumentsSpecified to use a valid temp directory for it's checkout path argument because SourceRepository init now guards against invalid checkout paths. Added a test to make sure SourceRepository guards against invalid checkout paths
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,18 +28,22 @@ class ConvertSubcommandSourceRepositoryTests: XCTestCase { | |
| )! | ||
|
|
||
| func testSourceRepositoryAllArgumentsSpecified() throws { | ||
| let checkoutPath = "checkout path" | ||
| var absoluteCheckoutPath = URL(fileURLWithPath: checkoutPath).absoluteString | ||
| let startIndex = absoluteCheckoutPath.index(absoluteCheckoutPath.startIndex, offsetBy: 7) | ||
| absoluteCheckoutPath = String(absoluteCheckoutPath[startIndex...]) | ||
| let tempDir = try createTemporaryDirectory(pathComponents: "addFileToCreateValidDirectory") | ||
|
|
||
| // removing file:// prefix from checkout path because the directory is not | ||
| // recognized as a valid directory with it | ||
| let checkoutPath = tempDir.absoluteString | ||
| let startIndex = checkoutPath.index(checkoutPath.startIndex, offsetBy: 7) | ||
| let absoluteCheckoutPath = String(checkoutPath[startIndex...]) | ||
|
|
||
|
|
||
| for sourceService in ["github", "gitlab", "bitbucket"] { | ||
| try assertSourceRepositoryArguments( | ||
| checkoutPath: checkoutPath, | ||
| checkoutPath: absoluteCheckoutPath, | ||
| sourceService: sourceService, | ||
| sourceServiceBaseURL: "https://example.com/path/to/base" | ||
| ) { action in | ||
| XCTAssertEqual(action.sourceRepository?.checkoutPath, absoluteCheckoutPath) | ||
| XCTAssertEqual(action.sourceRepository?.checkoutPath, "\(absoluteCheckoutPath)/") | ||
| XCTAssertEqual(action.sourceRepository?.sourceServiceBaseURL.absoluteString, "https://example.com/path/to/base") | ||
| } | ||
| } | ||
|
|
@@ -54,7 +58,29 @@ class ConvertSubcommandSourceRepositoryTests: XCTestCase { | |
| XCTAssertNil(action.sourceRepository) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| func testThrowsValidationErrorWhenCheckoutPathIsInvalid() throws { | ||
| let tempDir = try createTemporaryDirectory(named: "tmp").appendingPathComponent("InvalidDirectory", isDirectory: false) | ||
| let absoluteCheckoutPath = tempDir.absoluteString | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly, this test if verifying that using a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That test is checking that an error is thrown when a path is used as an argument, but the directories of the path don't exist. Specifically, it's testing this guard I added in SourceRepositoryArguments.swift guard FileManager.default.directoryExists(atPath: checkoutPath) else {
throw ValidationError("Checkout path directory '\(checkoutPath)' doesn't exist for --checkout-path argument.")
}To the end of the |
||
|
|
||
| for sourceService in ["github", "gitlab", "bitbucket"] { | ||
| XCTAssertThrowsError( | ||
| try assertSourceRepositoryArguments( | ||
| checkoutPath: absoluteCheckoutPath, | ||
| sourceService: sourceService, | ||
| sourceServiceBaseURL: "https://example.com/path/to/base" | ||
| ) | ||
| ) { error in | ||
| XCTAssertEqual( | ||
| (error as? ValidationError)?.message, | ||
| """ | ||
| Checkout path directory '\(absoluteCheckoutPath)' doesn't exist for --checkout-path argument. | ||
| """ | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func testThrowsValidationErrorWhenSourceServiceIsSpecifiedButNotSourceServiceBaseURL() throws { | ||
| XCTAssertThrowsError( | ||
| try assertSourceRepositoryArguments( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a significant amount of whitespace-only changes in all these files which adds noise to the PR. Please remove all those.