|
12 | 12 | // See the License for the specific language governing permissions and |
13 | 13 | // limitations under the License. |
14 | 14 |
|
15 | | -import Testing |
16 | | - |
17 | 15 | @testable import App |
18 | 16 |
|
19 | 17 | import Dependencies |
20 | 18 | import Fluent |
21 | 19 | import ShellOut |
22 | | - |
23 | | - |
24 | | -#warning("Move this") |
| 20 | +import Testing |
25 | 21 | import Vapor |
26 | | -private func withApp(_ setup: (Application) async throws -> Void = { _ in }, |
27 | | - _ updateValuesForOperation: (inout DependencyValues) async throws -> Void = { _ in }, |
28 | | - _ logHandler: LogHandler? = nil, |
29 | | - environment: Environment = .testing, |
30 | | - _ test: (Application) async throws -> Void) async throws { |
31 | | - try await AppTestCase.setupDb(environment) |
32 | | - let app = try await AppTestCase.setupApp(environment) |
33 | | - |
34 | | - return try await run { |
35 | | - try await setup(app) |
36 | | - try await withDependencies(updateValuesForOperation) { |
37 | | - let logger = logHandler.map { handler in Logger(label: "test", factory: { _ in handler }) } |
38 | | - try await withDependencies { |
39 | | - if let logger { |
40 | | - $0.logger.set(to: logger) |
41 | | - } |
42 | | - } operation: { |
43 | | - try await test(app) |
44 | | - } |
45 | | - } |
46 | | - } defer: { |
47 | | - try await app.asyncShutdown() |
48 | | - } |
49 | | -} |
50 | | - |
51 | | - |
52 | | - |
53 | | -private func defaultShellRun(command: ShellOutCommand, path: String) throws -> String { |
54 | | - switch command { |
55 | | - case .swiftDumpPackage where path.hasSuffix("foo-1"): |
56 | | - return packageSwift1 |
57 | | - |
58 | | - case .swiftDumpPackage where path.hasSuffix("foo-2"): |
59 | | - return packageSwift2 |
60 | | - |
61 | | - default: |
62 | | - return "" |
63 | | - } |
64 | | -} |
65 | 22 |
|
66 | 23 |
|
67 | 24 | // Test analysis error handling. |
@@ -257,6 +214,20 @@ extension AnalyzeErrorTests { |
257 | 214 | } |
258 | 215 |
|
259 | 216 |
|
| 217 | +private func defaultShellRun(command: ShellOutCommand, path: String) throws -> String { |
| 218 | + switch command { |
| 219 | + case .swiftDumpPackage where path.hasSuffix("foo-1"): |
| 220 | + return packageSwift1 |
| 221 | + |
| 222 | + case .swiftDumpPackage where path.hasSuffix("foo-2"): |
| 223 | + return packageSwift2 |
| 224 | + |
| 225 | + default: |
| 226 | + return "" |
| 227 | + } |
| 228 | +} |
| 229 | + |
| 230 | + |
260 | 231 | private extension GitClient { |
261 | 232 | struct SetupError: Error { } |
262 | 233 | static var analyzeErrorTestsMock: Self { |
|
0 commit comments