@@ -129,11 +129,11 @@ private func generateTestFileSystem(bundleArtifacts: [MockArtifact]) throws -> (
129
129
private let arm64Triple = try ! Triple ( " arm64-apple-macosx13.0 " )
130
130
private let i686Triple = try ! Triple ( " i686-apple-macosx13.0 " )
131
131
132
- private let fixtureArchivePath = try ! AbsolutePath ( validating: #file)
132
+ private let fixtureSDKsPath = try ! AbsolutePath ( validating: #file)
133
133
. parentDirectory
134
134
. parentDirectory
135
135
. parentDirectory
136
- . appending ( components: [ " Fixtures " , " SwiftSDKs " , " test-sdk.artifactbundle.tar.gz " ] )
136
+ . appending ( components: [ " Fixtures " , " SwiftSDKs " ] )
137
137
138
138
final class SwiftSDKBundleTests : XCTestCase {
139
139
func testInstallRemote( ) async throws {
@@ -142,43 +142,51 @@ final class SwiftSDKBundleTests: XCTestCase {
142
142
#endif
143
143
144
144
let system = ObservabilitySystem . makeForTesting ( )
145
- var output = [ SwiftSDKBundleStore . Output] ( )
146
145
let observabilityScope = system. topScope
147
146
let cancellator = Cancellator ( observabilityScope: observabilityScope)
148
147
let archiver = UniversalArchiver ( localFileSystem, cancellator)
149
148
150
- let httpClient = HTTPClient { request, _ in
151
- guard case let . download( _, downloadPath) = request. kind else {
152
- XCTFail ( " Unexpected HTTPClient.Request.Kind " )
153
- return . init( statusCode: 400 )
149
+ let fixtureAndURLs : [ ( url: String , fixture: String ) ] = [
150
+ ( " https://localhost/archive?test=foo " , " test-sdk.artifactbundle.tar.gz " ) ,
151
+ ( " https://localhost/archive.tar.gz " , " test-sdk.artifactbundle.tar.gz " ) ,
152
+ ( " https://localhost/archive.zip " , " test-sdk.artifactbundle.zip " ) ,
153
+ ]
154
+
155
+ for (bundleURLString, fixture) in fixtureAndURLs {
156
+ let httpClient = HTTPClient { request, _ in
157
+ guard case let . download( _, downloadPath) = request. kind else {
158
+ XCTFail ( " Unexpected HTTPClient.Request.Kind " )
159
+ return . init( statusCode: 400 )
160
+ }
161
+ let fixturePath = fixtureSDKsPath. appending ( component: fixture)
162
+ try localFileSystem. copy ( from: fixturePath, to: downloadPath)
163
+ return . init( statusCode: 200 )
154
164
}
155
- try localFileSystem. copy ( from: fixtureArchivePath, to: downloadPath)
156
- return . init( statusCode: 200 )
157
- }
158
165
159
- try await withTemporaryDirectory ( fileSystem: localFileSystem, removeTreeOnDeinit: true ) { tmpDir in
160
- let store = SwiftSDKBundleStore (
161
- swiftSDKsDirectory: tmpDir,
162
- fileSystem: localFileSystem,
163
- observabilityScope: observabilityScope,
164
- outputHandler: {
165
- output. append ( $0)
166
- }
167
- )
168
- let bundleURLString = " https://localhost/archive?test=foo "
169
- try await store. install ( bundlePathOrURL: bundleURLString, archiver, httpClient)
170
-
171
- let bundleURL = URL ( string: bundleURLString) !
172
- XCTAssertEqual ( output, [
173
- . downloadStarted( bundleURL) ,
174
- . downloadFinishedSuccessfully( bundleURL) ,
175
- . unpackingArchive( bundlePathOrURL: bundleURLString) ,
176
- . installationSuccessful(
177
- bundlePathOrURL: bundleURLString,
178
- bundleName: " test-sdk.artifactbundle "
179
- ) ,
180
- ] )
181
- } . value
166
+ try await withTemporaryDirectory ( fileSystem: localFileSystem, removeTreeOnDeinit: true ) { tmpDir in
167
+ var output = [ SwiftSDKBundleStore . Output] ( )
168
+ let store = SwiftSDKBundleStore (
169
+ swiftSDKsDirectory: tmpDir,
170
+ fileSystem: localFileSystem,
171
+ observabilityScope: observabilityScope,
172
+ outputHandler: {
173
+ output. append ( $0)
174
+ }
175
+ )
176
+ try await store. install ( bundlePathOrURL: bundleURLString, archiver, httpClient)
177
+
178
+ let bundleURL = URL ( string: bundleURLString) !
179
+ XCTAssertEqual ( output, [
180
+ . downloadStarted( bundleURL) ,
181
+ . downloadFinishedSuccessfully( bundleURL) ,
182
+ . unpackingArchive( bundlePathOrURL: bundleURLString) ,
183
+ . installationSuccessful(
184
+ bundlePathOrURL: bundleURLString,
185
+ bundleName: " test-sdk.artifactbundle "
186
+ ) ,
187
+ ] )
188
+ } . value
189
+ }
182
190
}
183
191
184
192
func testInstall( ) async throws {
0 commit comments