Skip to content

Commit 848e65d

Browse files
authored
feat: Update to Parse-Swift 5 (#18)
1 parent 5fb9209 commit 848e65d

File tree

4 files changed

+59
-48
lines changed

4 files changed

+59
-48
lines changed

Package.resolved

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ let package = Package(
1414
.library(name: "ParseServerSwift", targets: ["ParseServerSwift"])
1515
],
1616
dependencies: [
17-
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.69.1")),
17+
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.74.0")),
1818
.package(url: "https://github.com/netreconlab/Parse-Swift.git",
19-
.upToNextMajor(from: "5.0.0-beta.6")),
19+
.upToNextMajor(from: "5.1.0")),
2020
],
2121
targets: [
2222
.target(

Sources/ParseServerSwift/ParseServer.swift

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,22 @@ func initializeServer(_ configuration: ParseServerConfiguration,
5454
throw ParseError(code: .otherCause,
5555
message: "Could not make a URL from the Parse Server string")
5656
}
57-
58-
// Initialize the Parse-Swift SDK. Add any additional parameters you need
59-
try ParseSwift.initialize(applicationId: configuration.applicationId,
60-
primaryKey: configuration.primaryKey,
61-
serverURL: parseServerURL,
62-
// POST all queries instead of using GET.
63-
usingPostForQuery: true,
64-
// Do not use cache for anything.
65-
requestCachePolicy: .reloadIgnoringLocalCacheData) { _, completionHandler in
66-
// Setup to use default certificate pinning. See Parse-Swift docs for more info
67-
completionHandler(.performDefaultHandling, nil)
68-
}
6957

7058
if !configuration.isTesting {
7159
try setConfiguration(configuration)
7260
Task {
7361
do {
62+
// Initialize the Parse-Swift SDK. Add any additional parameters you need
63+
try await ParseSwift.initialize(applicationId: configuration.applicationId,
64+
primaryKey: configuration.primaryKey,
65+
serverURL: parseServerURL,
66+
// POST all queries instead of using GET.
67+
usingPostForQuery: true,
68+
// Do not use cache for anything.
69+
requestCachePolicy: .reloadIgnoringLocalCacheData) { _, completionHandler in
70+
// Setup to use default certificate pinning. See Parse-Swift docs for more info
71+
completionHandler(.performDefaultHandling, nil)
72+
}
7473
// Check the health of all Parse-Server
7574
try await checkServerHealth()
7675
} catch {

Tests/ParseServerSwiftTests/AppTests.swift

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ final class AppTests: XCTestCase {
99
var params: FooParameters
1010
}
1111

12-
func setupAppForTesting(hookKey: String? = nil) throws -> Application {
12+
func setupAppForTesting(hookKey: String? = nil) async throws -> Application {
1313
let app = Application(.testing)
1414
let configuration = try ParseServerConfiguration(app: app,
1515
hostName: "hostName",
@@ -19,6 +19,18 @@ final class AppTests: XCTestCase {
1919
webhookKey: hookKey,
2020
parseServerURLString: "primaryKey")
2121
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+
}
2234
try routes(app)
2335
return app
2436
}
@@ -41,8 +53,8 @@ final class AppTests: XCTestCase {
4153
XCTAssertNoThrow(try setConfiguration(configuration))
4254
}
4355

44-
func testDoNotInitConfigTwice() throws {
45-
let app = try setupAppForTesting()
56+
func testDoNotInitConfigTwice() async throws {
57+
let app = try await setupAppForTesting()
4658
defer { app.shutdown() }
4759
let configuration = try ParseServerConfiguration(app: app,
4860
hostName: "hostName",
@@ -53,8 +65,8 @@ final class AppTests: XCTestCase {
5365
XCTAssertThrowsError(try setConfiguration(configuration))
5466
}
5567

56-
func testFooBar() throws {
57-
let app = try setupAppForTesting()
68+
func testFooBar() async throws {
69+
let app = try await setupAppForTesting()
5870
defer { app.shutdown() }
5971

6072
try app.test(.GET, "foo", afterResponse: { res in
@@ -64,7 +76,7 @@ final class AppTests: XCTestCase {
6476
}
6577

6678
func testCheckServerHealth() async throws {
67-
let app = try setupAppForTesting()
79+
let app = try await setupAppForTesting()
6880
defer { app.shutdown() }
6981

7082
XCTAssertGreaterThan(configuration.parseServerURLStrings.count, 0)
@@ -93,7 +105,7 @@ final class AppTests: XCTestCase {
93105
}
94106

95107
func testDeleteHooks() async throws {
96-
let app = try setupAppForTesting()
108+
let app = try await setupAppForTesting()
97109
defer { app.shutdown() }
98110

99111
let urlString = "https://parse.com/parse"
@@ -122,8 +134,8 @@ final class AppTests: XCTestCase {
122134
XCTAssertEqual(currentTriggers2.count, 0)
123135
}
124136

125-
func testFunctionWebhookKeyNotEqual() throws {
126-
let app = try setupAppForTesting(hookKey: "wow")
137+
func testFunctionWebhookKeyNotEqual() async throws {
138+
let app = try await setupAppForTesting(hookKey: "wow")
127139
defer { app.shutdown() }
128140

129141
try app.test(.POST, "hello", afterResponse: { res in
@@ -132,8 +144,8 @@ final class AppTests: XCTestCase {
132144
})
133145
}
134146

135-
func testTriggerWebhookKeyNotEqual() throws {
136-
let app = try setupAppForTesting(hookKey: "wow")
147+
func testTriggerWebhookKeyNotEqual() async throws {
148+
let app = try await setupAppForTesting(hookKey: "wow")
137149
defer { app.shutdown() }
138150

139151
try app.test(.POST, "score/save/before", afterResponse: { res in
@@ -143,7 +155,7 @@ final class AppTests: XCTestCase {
143155
}
144156

145157
func testMatchServerURLString() async throws {
146-
let app = try setupAppForTesting()
158+
let app = try await setupAppForTesting()
147159
defer { app.shutdown() }
148160
let urlString = "https://parse.com/parse"
149161
let uri = URI(stringLiteral: urlString)
@@ -162,7 +174,7 @@ final class AppTests: XCTestCase {
162174
}
163175

164176
func testMatchServerURLStringThrowsError() async throws {
165-
let app = try setupAppForTesting()
177+
let app = try await setupAppForTesting()
166178
ParseServer.configuration.parseServerURLStrings.removeAll()
167179
defer { app.shutdown() }
168180
let urlString = "https://parse.com/parse"
@@ -172,7 +184,7 @@ final class AppTests: XCTestCase {
172184
}
173185

174186
func testParseHookOptions() async throws {
175-
let app = try setupAppForTesting()
187+
let app = try await setupAppForTesting()
176188
defer { app.shutdown() }
177189
let installationId = "naw"
178190
let urlString = "https://parse.com/parse"

0 commit comments

Comments
 (0)