@@ -9,7 +9,7 @@ final class AppTests: XCTestCase {
9
9
var params : FooParameters
10
10
}
11
11
12
- func setupAppForTesting( hookKey: String ? = nil ) throws -> Application {
12
+ func setupAppForTesting( hookKey: String ? = nil ) async throws -> Application {
13
13
let app = Application ( . testing)
14
14
let configuration = try ParseServerConfiguration ( app: app,
15
15
hostName: " hostName " ,
@@ -19,6 +19,18 @@ final class AppTests: XCTestCase {
19
19
webhookKey: hookKey,
20
20
parseServerURLString: " primaryKey " )
21
21
try ParseServerSwift . initialize ( configuration, app: app, testing: true )
22
+ guard let parseServerURL = URL ( string: configuration. primaryParseServerURLString) else {
23
+ throw ParseError ( code: . otherCause,
24
+ message: " Could not make a URL from the Parse Server string " )
25
+ }
26
+ try await ParseSwift . initialize ( applicationId: configuration. applicationId,
27
+ primaryKey: configuration. primaryKey,
28
+ serverURL: parseServerURL,
29
+ usingPostForQuery: true ,
30
+ requestCachePolicy: . reloadIgnoringLocalCacheData) { _, completionHandler in
31
+ // Setup to use default certificate pinning. See Parse-Swift docs for more info
32
+ completionHandler ( . performDefaultHandling, nil )
33
+ }
22
34
try routes ( app)
23
35
return app
24
36
}
@@ -41,8 +53,8 @@ final class AppTests: XCTestCase {
41
53
XCTAssertNoThrow ( try setConfiguration ( configuration) )
42
54
}
43
55
44
- func testDoNotInitConfigTwice( ) throws {
45
- let app = try setupAppForTesting ( )
56
+ func testDoNotInitConfigTwice( ) async throws {
57
+ let app = try await setupAppForTesting ( )
46
58
defer { app. shutdown ( ) }
47
59
let configuration = try ParseServerConfiguration ( app: app,
48
60
hostName: " hostName " ,
@@ -53,8 +65,8 @@ final class AppTests: XCTestCase {
53
65
XCTAssertThrowsError ( try setConfiguration ( configuration) )
54
66
}
55
67
56
- func testFooBar( ) throws {
57
- let app = try setupAppForTesting ( )
68
+ func testFooBar( ) async throws {
69
+ let app = try await setupAppForTesting ( )
58
70
defer { app. shutdown ( ) }
59
71
60
72
try app. test ( . GET, " foo " , afterResponse: { res in
@@ -64,7 +76,7 @@ final class AppTests: XCTestCase {
64
76
}
65
77
66
78
func testCheckServerHealth( ) async throws {
67
- let app = try setupAppForTesting ( )
79
+ let app = try await setupAppForTesting ( )
68
80
defer { app. shutdown ( ) }
69
81
70
82
XCTAssertGreaterThan ( configuration. parseServerURLStrings. count, 0 )
@@ -93,7 +105,7 @@ final class AppTests: XCTestCase {
93
105
}
94
106
95
107
func testDeleteHooks( ) async throws {
96
- let app = try setupAppForTesting ( )
108
+ let app = try await setupAppForTesting ( )
97
109
defer { app. shutdown ( ) }
98
110
99
111
let urlString = " https://parse.com/parse "
@@ -122,8 +134,8 @@ final class AppTests: XCTestCase {
122
134
XCTAssertEqual ( currentTriggers2. count, 0 )
123
135
}
124
136
125
- func testFunctionWebhookKeyNotEqual( ) throws {
126
- let app = try setupAppForTesting ( hookKey: " wow " )
137
+ func testFunctionWebhookKeyNotEqual( ) async throws {
138
+ let app = try await setupAppForTesting ( hookKey: " wow " )
127
139
defer { app. shutdown ( ) }
128
140
129
141
try app. test ( . POST, " hello " , afterResponse: { res in
@@ -132,8 +144,8 @@ final class AppTests: XCTestCase {
132
144
} )
133
145
}
134
146
135
- func testTriggerWebhookKeyNotEqual( ) throws {
136
- let app = try setupAppForTesting ( hookKey: " wow " )
147
+ func testTriggerWebhookKeyNotEqual( ) async throws {
148
+ let app = try await setupAppForTesting ( hookKey: " wow " )
137
149
defer { app. shutdown ( ) }
138
150
139
151
try app. test ( . POST, " score/save/before " , afterResponse: { res in
@@ -143,7 +155,7 @@ final class AppTests: XCTestCase {
143
155
}
144
156
145
157
func testMatchServerURLString( ) async throws {
146
- let app = try setupAppForTesting ( )
158
+ let app = try await setupAppForTesting ( )
147
159
defer { app. shutdown ( ) }
148
160
let urlString = " https://parse.com/parse "
149
161
let uri = URI ( stringLiteral: urlString)
@@ -162,7 +174,7 @@ final class AppTests: XCTestCase {
162
174
}
163
175
164
176
func testMatchServerURLStringThrowsError( ) async throws {
165
- let app = try setupAppForTesting ( )
177
+ let app = try await setupAppForTesting ( )
166
178
ParseServer . configuration. parseServerURLStrings. removeAll ( )
167
179
defer { app. shutdown ( ) }
168
180
let urlString = " https://parse.com/parse "
@@ -172,7 +184,7 @@ final class AppTests: XCTestCase {
172
184
}
173
185
174
186
func testParseHookOptions( ) async throws {
175
- let app = try setupAppForTesting ( )
187
+ let app = try await setupAppForTesting ( )
176
188
defer { app. shutdown ( ) }
177
189
let installationId = " naw "
178
190
let urlString = " https://parse.com/parse "
0 commit comments