@@ -162,57 +162,57 @@ private func defaultShellRun(command: ShellOutCommand, path: String) throws -> S
162162 }
163163
164164 @Test func analyze_getPackageInfo_gitCheckout_error( ) async throws {
165- try await withDependencies {
166- $0. environment. loadSPIManifest = { _ in nil }
167- $0. fileManager. fileExists = { @Sendable _ in true }
168- $0. shell. run = { @Sendable cmd, path in
169- switch cmd {
170- case . gitCheckout( branch: " main " , quiet: true ) where path. hasSuffix ( " foo-1 " ) :
171- throw SimulatedError ( )
172-
173- default :
174- return try defaultShellRun ( command: cmd, path: path)
165+ try await withApp ( setup, defaultDependencies, capturingLogger) { app in
166+ try await withDependencies {
167+ $0. environment. loadSPIManifest = { _ in nil }
168+ $0. fileManager. fileExists = { @Sendable _ in true }
169+ $0. shell. run = { @Sendable cmd, path in
170+ switch cmd {
171+ case . gitCheckout( branch: " main " , quiet: true ) where path. hasSuffix ( " foo-1 " ) :
172+ throw SimulatedError ( )
173+
174+ default :
175+ return try defaultShellRun ( command: cmd, path: path)
176+ }
175177 }
176- }
177- } operation: {
178- try await withApp ( setup) { app in
178+ } operation: {
179179 // MUT
180180 try await Analyze . analyze ( client: app. client, database: app. db, mode: . limit( 10 ) )
181181
182182 // validate
183183 try await defaultValidation ( app)
184- // try logger .logs.withValue { logs in
185- // #expect(logs.count == 2)
186- // let error = try logs.last.unwrap()
187- // #expect(error.message.contains("AppError.noValidVersions"), "was: \(error.message)")
188- // }
184+ try capturingLogger . logs. withValue { logs in
185+ #expect( logs. count == 2 )
186+ let error = try logs. last. unwrap ( )
187+ #expect( error. message. contains ( " AppError.noValidVersions " ) , " was: \( error. message) " )
188+ }
189189 }
190190 }
191191 }
192192
193193 @Test func analyze_dumpPackage_missing_manifest( ) async throws {
194- try await withDependencies {
195- $0. environment. loadSPIManifest = { _ in nil }
196- $0. fileManager. fileExists = { @Sendable path in
197- if path. hasSuffix ( " github.com-foo-1/Package.swift " ) {
198- return false
194+ try await withApp ( setup, defaultDependencies, capturingLogger) { app in
195+ try await withDependencies {
196+ $0. environment. loadSPIManifest = { _ in nil }
197+ $0. fileManager. fileExists = { @Sendable path in
198+ if path. hasSuffix ( " github.com-foo-1/Package.swift " ) {
199+ return false
200+ }
201+ return true
199202 }
200- return true
201- }
202- } operation: {
203- try await withApp ( setup) { app in
203+ } operation: {
204204 // MUT
205205 try await Analyze . analyze ( client: app. client,
206206 database: app. db,
207207 mode: . limit( 10 ) )
208208
209209 // validate
210210 try await defaultValidation ( app)
211- // try logger .logs.withValue { logs in
212- // #expect(logs.count == 2)
213- // let error = try logs.last.unwrap()
214- // #expect(error.message.contains("AppError.noValidVersions"), "was: \(error.message)")
215- // }
211+ try capturingLogger . logs. withValue { logs in
212+ #expect( logs. count == 2 )
213+ let error = try logs. last. unwrap ( )
214+ #expect( error. message. contains ( " AppError.noValidVersions " ) , " was: \( error. message) " )
215+ }
216216 }
217217 }
218218 }
0 commit comments