@@ -20,26 +20,31 @@ class ConvertSubcommandSourceRepositoryTests: XCTestCase {
2020 withExtension: " docc " ,
2121 subdirectory: " Test Bundles "
2222 ) !
23-
23+
2424 private let testTemplateURL = Bundle . module. url (
2525 forResource: " Test Template " ,
2626 withExtension: nil ,
2727 subdirectory: " Test Resources "
2828 ) !
29-
29+
3030 func testSourceRepositoryAllArgumentsSpecified( ) throws {
31+ let checkoutPath = " checkout path "
32+ var absoluteCheckoutPath = URL ( fileURLWithPath: checkoutPath) . absoluteString
33+ let startIndex = absoluteCheckoutPath. index ( absoluteCheckoutPath. startIndex, offsetBy: 7 )
34+ absoluteCheckoutPath = String ( absoluteCheckoutPath [ startIndex... ] )
35+
3136 for sourceService in [ " github " , " gitlab " , " bitbucket " ] {
3237 try assertSourceRepositoryArguments (
33- checkoutPath: " checkout path " ,
38+ checkoutPath: checkoutPath ,
3439 sourceService: sourceService,
3540 sourceServiceBaseURL: " https://example.com/path/to/base "
3641 ) { action in
37- XCTAssertEqual ( action. sourceRepository? . checkoutPath, " checkout path " )
42+ XCTAssertEqual ( action. sourceRepository? . checkoutPath, absoluteCheckoutPath )
3843 XCTAssertEqual ( action. sourceRepository? . sourceServiceBaseURL. absoluteString, " https://example.com/path/to/base " )
3944 }
4045 }
4146 }
42-
47+
4348 func testDoesNotSetSourceRepositoryIfBothCheckoutPathAndsourceServiceBaseURLArgumentsAreMissing( ) throws {
4449 try assertSourceRepositoryArguments (
4550 checkoutPath: nil ,
@@ -49,7 +54,7 @@ class ConvertSubcommandSourceRepositoryTests: XCTestCase {
4954 XCTAssertNil ( action. sourceRepository)
5055 }
5156 }
52-
57+
5358 func testThrowsValidationErrorWhenSourceServiceIsSpecifiedButNotSourceServiceBaseURL( ) throws {
5459 XCTAssertThrowsError (
5560 try assertSourceRepositoryArguments (
@@ -67,7 +72,7 @@ class ConvertSubcommandSourceRepositoryTests: XCTestCase {
6772 )
6873 }
6974 }
70-
75+
7176 func testThrowsValidationErrorWhenSourceServiceBaseURLIsSpecifiedButNotSourceService( ) throws {
7277 XCTAssertThrowsError (
7378 try assertSourceRepositoryArguments (
@@ -85,7 +90,7 @@ class ConvertSubcommandSourceRepositoryTests: XCTestCase {
8590 )
8691 }
8792 }
88-
93+
8994 func testThrowsValidationErrorWhenSourceServiceBaseURLIsInvalid( ) throws {
9095 XCTAssertThrowsError (
9196 try assertSourceRepositoryArguments (
@@ -100,7 +105,7 @@ class ConvertSubcommandSourceRepositoryTests: XCTestCase {
100105 )
101106 }
102107 }
103-
108+
104109 func testThrowsValidationErrorWhenCheckoutPathIsNotSpecified( ) throws {
105110 XCTAssertThrowsError (
106111 try assertSourceRepositoryArguments (
@@ -118,7 +123,7 @@ class ConvertSubcommandSourceRepositoryTests: XCTestCase {
118123 )
119124 }
120125 }
121-
126+
122127 func testThrowsValidationErrorWhenSourceServiceIsInvalid( ) throws {
123128 XCTAssertThrowsError (
124129 try assertSourceRepositoryArguments (
@@ -133,15 +138,15 @@ class ConvertSubcommandSourceRepositoryTests: XCTestCase {
133138 )
134139 }
135140 }
136-
141+
137142 private func assertSourceRepositoryArguments(
138143 checkoutPath: String ? ,
139144 sourceService: String ? ,
140145 sourceServiceBaseURL: String ? ,
141146 assertion: ( ( ConvertAction ) throws -> Void ) ? = nil
142147 ) throws {
143148 SetEnvironmentVariable ( TemplateOption . environmentVariableKey, testTemplateURL. path)
144-
149+
145150 var arguments : [ String ] = [ testBundleURL. path]
146151 if let checkoutPath {
147152 arguments. append ( contentsOf: [ " --checkout-path " , checkoutPath] )
@@ -152,9 +157,9 @@ class ConvertSubcommandSourceRepositoryTests: XCTestCase {
152157 if let sourceServiceBaseURL {
153158 arguments. append ( contentsOf: [ " --source-service-base-url " , sourceServiceBaseURL] )
154159 }
155-
160+
156161 let convertOptions = try Docc . Convert. parse ( arguments)
157-
162+
158163 let result = try ConvertAction ( fromConvertCommand: convertOptions)
159164 try assertion ? ( result)
160165 }
0 commit comments