@@ -10,7 +10,7 @@ final class AppTests: XCTestCase {
1010 }
1111
1212 func setupAppForTesting( hookKey: String ? = nil ) async throws -> Application {
13- let app = Application ( . testing)
13+ let app = try await Application . make ( . testing)
1414 let configuration = try ParseServerConfiguration ( app: app,
1515 hostName: " hostName " ,
1616 port: 8080 ,
@@ -35,49 +35,52 @@ final class AppTests: XCTestCase {
3535 return app
3636 }
3737
38- func testConfigRequiresKeys( ) throws {
39- let app = Application ( . testing)
40- defer { app. shutdown ( ) }
38+ func testConfigRequiresKeys( ) async throws {
39+ let app = try await Application . make ( . testing)
4140 XCTAssertThrowsError ( try ParseServerConfiguration ( app: app) )
41+ try await app. asyncShutdown ( )
4242 }
4343
44- func testAllowInitConfigOnce( ) throws {
45- let app = Application ( . testing)
46- defer { app. shutdown ( ) }
44+ func testAllowInitConfigOnce( ) async throws {
45+ let app = try await Application . make ( . testing)
4746 let configuration = try ParseServerConfiguration ( app: app,
4847 hostName: " hostName " ,
4948 port: 8080 ,
5049 applicationId: " applicationId " ,
5150 primaryKey: " primaryKey " ,
5251 parseServerURLString: " primaryKey " )
5352 XCTAssertNoThrow ( try setConfiguration ( configuration) )
53+ try await app. asyncShutdown ( )
5454 }
5555
5656 func testDoNotInitConfigTwice( ) async throws {
5757 let app = try await setupAppForTesting ( )
58- defer { app. shutdown ( ) }
5958 let configuration = try ParseServerConfiguration ( app: app,
6059 hostName: " hostName " ,
6160 port: 8080 ,
6261 applicationId: " applicationId " ,
6362 primaryKey: " primaryKey " ,
6463 parseServerURLString: " primaryKey " )
6564 XCTAssertThrowsError ( try setConfiguration ( configuration) )
65+ try await app. asyncShutdown ( )
6666 }
6767
6868 func testFooBar( ) async throws {
6969 let app = try await setupAppForTesting ( )
70- defer { app. shutdown ( ) }
7170
72- try app. test ( . GET, " foo " , afterResponse: { res in
71+ try await app. test (
72+ . GET,
73+ " foo "
74+ ) { res async throws in
7375 XCTAssertEqual ( res. status, . ok)
7476 XCTAssertEqual ( res. body. string, " foo bar " )
75- } )
77+ }
78+
79+ try await app. asyncShutdown ( )
7680 }
7781
7882 func testCheckServerHealth( ) async throws {
7983 let app = try await setupAppForTesting ( )
80- defer { app. shutdown ( ) }
8184
8285 XCTAssertGreaterThan ( configuration. parseServerURLStrings. count, 0 )
8386 do {
@@ -86,6 +89,7 @@ final class AppTests: XCTestCase {
8689 } catch {
8790 XCTAssertTrue ( error. localizedDescription. contains ( " Unable to connect " ) )
8891 }
92+ try await app. asyncShutdown ( )
8993 }
9094
9195 func testGetParseServerURLs( ) async throws {
@@ -106,7 +110,6 @@ final class AppTests: XCTestCase {
106110
107111 func testDeleteHooks( ) async throws {
108112 let app = try await setupAppForTesting ( )
109- defer { app. shutdown ( ) }
110113
111114 let urlString = " https://parse.com/parse "
112115 guard let url = URL ( string: urlString) else {
@@ -132,31 +135,39 @@ final class AppTests: XCTestCase {
132135 let currentTriggers2 = await configuration. hooks. getTriggers ( )
133136 XCTAssertEqual ( currentFunctions2. count, 0 )
134137 XCTAssertEqual ( currentTriggers2. count, 0 )
138+ try await app. asyncShutdown ( )
135139 }
136140
137141 func testFunctionWebhookKeyNotEqual( ) async throws {
138142 let app = try await setupAppForTesting ( hookKey: " wow " )
139- defer { app. shutdown ( ) }
140143
141- try app. test ( . POST, " hello " , afterResponse: { res in
144+ try await app. test (
145+ . POST,
146+ " hello "
147+ ) { res async throws in
142148 XCTAssertEqual ( res. status, . ok)
143149 XCTAssertTrue ( res. body. string. contains ( " Webhook keys " ) )
144- } )
150+ }
151+
152+ try await app. asyncShutdown ( )
145153 }
146154
147155 func testTriggerWebhookKeyNotEqual( ) async throws {
148156 let app = try await setupAppForTesting ( hookKey: " wow " )
149- defer { app. shutdown ( ) }
150157
151- try app. test ( . POST, " score/save/before " , afterResponse: { res in
158+ try await app. test (
159+ . POST,
160+ " score/save/before "
161+ ) { res async throws in
152162 XCTAssertEqual ( res. status, . ok)
153163 XCTAssertTrue ( res. body. string. contains ( " Webhook keys " ) )
154- } )
164+ }
165+
166+ try await app. asyncShutdown ( )
155167 }
156168
157169 func testMatchServerURLString( ) async throws {
158170 let app = try await setupAppForTesting ( )
159- defer { app. shutdown ( ) }
160171 let urlString = " https://parse.com/parse "
161172 let uri = URI ( stringLiteral: urlString)
162173 let serverString = try serverURLString ( uri, parseServerURLStrings: [ urlString] )
@@ -171,21 +182,22 @@ final class AppTests: XCTestCase {
171182 let serverString3 = try serverURLString ( uri,
172183 parseServerURLStrings: configuration. parseServerURLStrings)
173184 XCTAssertEqual ( serverString3, configuration. parseServerURLStrings. first)
185+
186+ try await app. asyncShutdown ( )
174187 }
175188
176189 func testMatchServerURLStringThrowsError( ) async throws {
177190 let app = try await setupAppForTesting ( )
178191 Parse . configuration. parseServerURLStrings. removeAll ( )
179- defer { app. shutdown ( ) }
180192 let urlString = " https://parse.com/parse "
181193 let uri = URI ( stringLiteral: urlString)
182194 XCTAssertThrowsError ( try serverURLString ( uri,
183195 parseServerURLStrings: configuration. parseServerURLStrings) )
196+ try await app. asyncShutdown ( )
184197 }
185198
186199 func testParseHookOptions( ) async throws {
187200 let app = try await setupAppForTesting ( )
188- defer { app. shutdown ( ) }
189201 let installationId = " naw "
190202 let urlString = " https://parse.com/parse "
191203 Parse . configuration. parseServerURLStrings. append ( urlString)
@@ -208,6 +220,7 @@ final class AppTests: XCTestCase {
208220 XCTAssertEqual ( options2. count, 2 )
209221 XCTAssertTrue ( installationOption2. debugDescription. contains ( installationId) )
210222 XCTAssertTrue ( serverURLOption. debugDescription. contains ( " \" \( urlString) \" " ) )
223+ try await app. asyncShutdown ( )
211224 }
212225
213226 func testHooksFunctions( ) async throws {
0 commit comments