@@ -113,11 +113,11 @@ private func generateTestFileSystem(bundleArtifacts: [MockArtifact]) throws -> (
113113private let arm64Triple = try ! Triple ( " arm64-apple-macosx13.0 " )
114114private let i686Triple = try ! Triple ( " i686-apple-macosx13.0 " )
115115
116- private let fixtureArchivePath = try ! AbsolutePath ( validating: #file)
116+ private let fixtureSDKsPath = try ! AbsolutePath ( validating: #file)
117117 . parentDirectory
118118 . parentDirectory
119119 . parentDirectory
120- . appending ( components: [ " Fixtures " , " SwiftSDKs " , " test-sdk.artifactbundle.tar.gz " ] )
120+ . appending ( components: [ " Fixtures " , " SwiftSDKs " ] )
121121
122122final class SwiftSDKBundleTests : XCTestCase {
123123 func testInstallRemote( ) async throws {
@@ -126,43 +126,51 @@ final class SwiftSDKBundleTests: XCTestCase {
126126 #endif
127127
128128 let system = ObservabilitySystem . makeForTesting ( )
129- var output = [ SwiftSDKBundleStore . Output] ( )
130129 let observabilityScope = system. topScope
131130 let cancellator = Cancellator ( observabilityScope: observabilityScope)
132131 let archiver = UniversalArchiver ( localFileSystem, cancellator)
133132
134- let httpClient = HTTPClient { request, _ in
135- guard case let . download( _, downloadPath) = request. kind else {
136- XCTFail ( " Unexpected HTTPClient.Request.Kind " )
137- return . init( statusCode: 400 )
133+ let fixtureAndURLs : [ ( url: String , fixture: String ) ] = [
134+ ( " https://localhost/archive?test=foo " , " test-sdk.artifactbundle.tar.gz " ) ,
135+ ( " https://localhost/archive.tar.gz " , " test-sdk.artifactbundle.tar.gz " ) ,
136+ ( " https://localhost/archive.zip " , " test-sdk.artifactbundle.zip " ) ,
137+ ]
138+
139+ for (bundleURLString, fixture) in fixtureAndURLs {
140+ let httpClient = HTTPClient { request, _ in
141+ guard case let . download( _, downloadPath) = request. kind else {
142+ XCTFail ( " Unexpected HTTPClient.Request.Kind " )
143+ return . init( statusCode: 400 )
144+ }
145+ let fixturePath = fixtureSDKsPath. appending ( component: fixture)
146+ try localFileSystem. copy ( from: fixturePath, to: downloadPath)
147+ return . init( statusCode: 200 )
138148 }
139- try localFileSystem. copy ( from: fixtureArchivePath, to: downloadPath)
140- return . init( statusCode: 200 )
141- }
142149
143- try await withTemporaryDirectory ( fileSystem: localFileSystem, removeTreeOnDeinit: true ) { tmpDir in
144- let store = SwiftSDKBundleStore (
145- swiftSDKsDirectory: tmpDir,
146- fileSystem: localFileSystem,
147- observabilityScope: observabilityScope,
148- outputHandler: {
149- output. append ( $0)
150- }
151- )
152- let bundleURLString = " https://localhost/archive?test=foo "
153- try await store. install ( bundlePathOrURL: bundleURLString, archiver, httpClient)
154-
155- let bundleURL = URL ( string: bundleURLString) !
156- XCTAssertEqual ( output, [
157- . downloadStarted( bundleURL) ,
158- . downloadFinishedSuccessfully( bundleURL) ,
159- . unpackingArchive( bundlePathOrURL: bundleURLString) ,
160- . installationSuccessful(
161- bundlePathOrURL: bundleURLString,
162- bundleName: " test-sdk.artifactbundle "
163- ) ,
164- ] )
165- } . value
150+ try await withTemporaryDirectory ( fileSystem: localFileSystem, removeTreeOnDeinit: true ) { tmpDir in
151+ var output = [ SwiftSDKBundleStore . Output] ( )
152+ let store = SwiftSDKBundleStore (
153+ swiftSDKsDirectory: tmpDir,
154+ fileSystem: localFileSystem,
155+ observabilityScope: observabilityScope,
156+ outputHandler: {
157+ output. append ( $0)
158+ }
159+ )
160+ try await store. install ( bundlePathOrURL: bundleURLString, archiver, httpClient)
161+
162+ let bundleURL = URL ( string: bundleURLString) !
163+ XCTAssertEqual ( output, [
164+ . downloadStarted( bundleURL) ,
165+ . downloadFinishedSuccessfully( bundleURL) ,
166+ . unpackingArchive( bundlePathOrURL: bundleURLString) ,
167+ . installationSuccessful(
168+ bundlePathOrURL: bundleURLString,
169+ bundleName: " test-sdk.artifactbundle "
170+ ) ,
171+ ] )
172+ } . value
173+ }
166174 }
167175
168176 func testInstall( ) async throws {
0 commit comments