@@ -113,11 +113,11 @@ private func generateTestFileSystem(bundleArtifacts: [MockArtifact]) throws -> (
113
113
private let arm64Triple = try ! Triple ( " arm64-apple-macosx13.0 " )
114
114
private let i686Triple = try ! Triple ( " i686-apple-macosx13.0 " )
115
115
116
- private let fixtureArchivePath = try ! AbsolutePath ( validating: #file)
116
+ private let fixtureSDKsPath = try ! AbsolutePath ( validating: #file)
117
117
. parentDirectory
118
118
. parentDirectory
119
119
. parentDirectory
120
- . appending ( components: [ " Fixtures " , " SwiftSDKs " , " test-sdk.artifactbundle.tar.gz " ] )
120
+ . appending ( components: [ " Fixtures " , " SwiftSDKs " ] )
121
121
122
122
final class SwiftSDKBundleTests : XCTestCase {
123
123
func testInstallRemote( ) async throws {
@@ -126,43 +126,51 @@ final class SwiftSDKBundleTests: XCTestCase {
126
126
#endif
127
127
128
128
let system = ObservabilitySystem . makeForTesting ( )
129
- var output = [ SwiftSDKBundleStore . Output] ( )
130
129
let observabilityScope = system. topScope
131
130
let cancellator = Cancellator ( observabilityScope: observabilityScope)
132
131
let archiver = UniversalArchiver ( localFileSystem, cancellator)
133
132
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 )
138
148
}
139
- try localFileSystem. copy ( from: fixtureArchivePath, to: downloadPath)
140
- return . init( statusCode: 200 )
141
- }
142
149
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
+ }
166
174
}
167
175
168
176
func testInstall( ) async throws {
0 commit comments