Skip to content

Commit

Permalink
refactor: Switch mounting point for Playgrounds (#52)
Browse files Browse the repository at this point in the history
* refactor: Switch mounting point for Playgrounds

* decode hook names

* fix broken tests

* switch to string
  • Loading branch information
cbaker6 committed Jan 24, 2023
1 parent cbfed65 commit de696cc
Show file tree
Hide file tree
Showing 120 changed files with 210 additions and 203 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ __New features__
* The max connection attempts for LiveQuery can now be changed when initializing the SDK ([#43](https://github.com/netreconlab/Parse-Swift/pull/43)), thanks to [Corey Baker](https://github.com/cbaker6).

__Fixes__
* Refactored playground mount to be "/parse" instead "/1". Also do not require url when decoding a ParseFile ([#52](https://github.com/netreconlab/Parse-Swift/pull/52)), thanks to [Corey Baker](https://github.com/cbaker6).
* Fixed issues that can cause cache misses when querying ([#46](https://github.com/netreconlab/Parse-Swift/pull/46)), thanks to [Corey Baker](https://github.com/cbaker6).
* Fixed a threading issue with .current objects that can cause apps to crash
([#45](https://github.com/netreconlab/Parse-Swift/pull/45)), thanks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PlaygroundPage.current.needsIndefiniteExecution = true

/*:
Start your parse-server with:
npm start -- --appId applicationId --clientKey clientKey --masterKey primaryKey --mountPath /1
npm start -- --appId applicationId --clientKey clientKey --masterKey primaryKey --mountPath /parse
*/

do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PlaygroundPage.current.needsIndefiniteExecution = true

/*:
Start parse-server with:
npm start -- --appId applicationId --clientKey clientKey --masterKey primaryKey --mountPath /1
npm start -- --appId applicationId --clientKey clientKey --masterKey primaryKey --mountPath /parse
*/

do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct User: ParseUser {
queue and returns to specified callbackQueue.
If no callbackQueue is specified it returns to main queue.
*/
User.signup(username: "hello", password: "world") { results in
User.signup(username: "hello", password: "TestMePass123^") { results in

switch results {
case .success(let user):
Expand All @@ -77,7 +77,7 @@ User.signup(username: "hello", password: "world") { results in

//: You can verify the password of the user.
//: Note that usingPost should be set to **true** on newer servers.
User.verifyPassword(password: "world", usingPost: false) { results in
User.verifyPassword(password: "TestMePass123^", usingPost: false) { results in

switch results {
case .success(let user):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ do {
queue and returns to specified callbackQueue.
If no callbackQueue is specified it returns to main queue.
*/
User.login(username: "hello", password: "world") { result in
User.login(username: "hello", password: "TestMePass123^") { result in

switch result {
case .success(let user):
Expand Down Expand Up @@ -258,7 +258,7 @@ User.anonymous.login { result in
//: Convert the anonymous user to a real new user.
var currentUser2 = User.current
currentUser2?.username = "bye"
currentUser2?.password = "world"
currentUser2?.password = "HelloMePass123^"
currentUser2?.signup { result in
switch result {

Expand Down
2 changes: 1 addition & 1 deletion ParseSwift.playground/Sources/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public func initializeParse(customObjectId: Bool = false) throws {
try ParseSwift.initialize(applicationId: "applicationId",
clientKey: "clientKey",
primaryKey: "primaryKey",
serverURL: URL(string: "http://localhost:1337/1")!,
serverURL: URL(string: "http://localhost:1337/parse")!,
requiringCustomObjectIds: customObjectId,
usingEqualQueryConstraint: false,
usingDataProtectionKeychain: false)
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/ParseConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

enum ParseConstants {
static let sdk = "swift"
static let version = "5.0.0-beta.4"
static let version = "5.0.0-beta.5"
static let fileManagementDirectory = "parse/"
static let fileManagementPrivateDocumentsDirectory = "Private Documents/"
static let fileManagementLibraryDirectory = "Library/"
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/Types/ParseFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ extension ParseFile {
extension ParseFile {
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
url = try values.decode(URL.self, forKey: .url)
url = try values.decodeIfPresent(URL.self, forKey: .url)
name = try values.decode(String.self, forKey: .name)
id = UUID()
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/ParseSwift/Types/ParseHookFunctionRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public struct ParseHookFunctionRequest<U: ParseCloudUser, P: ParseHookParametabl
public var installationId: String?
public var ipAddress: String?
public var headers: [String: String]?
/// The name of Parse Hook Function.
public var functionName: String?
/**
The `ParseHookParametable` object containing the parameters passed
to the function.
Expand All @@ -33,7 +35,7 @@ public struct ParseHookFunctionRequest<U: ParseCloudUser, P: ParseHookParametabl
case primaryKey = "master"
case parameters = "params"
case ipAddress = "ip"
case user, installationId,
case user, installationId, functionName,
headers, log, context
}
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/ParseSwift/Types/ParseHookTriggerRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public struct ParseHookTriggerRequest<U: ParseCloudUser, T: ParseObject>: ParseH
public var installationId: String?
public var ipAddress: String?
public var headers: [String: String]?
/// The types of Parse Hook Trigger.
public var triggerName: String?
/// An object from the hook call.
public var object: T?
/// The results the query yielded..
Expand Down Expand Up @@ -58,7 +60,7 @@ public struct ParseHookTriggerRequest<U: ParseCloudUser, T: ParseObject>: ParseH
log, context, object, objects,
original, query, file, fileSize,
isGet, contentLength, clients,
subscriptions, sendEvent
subscriptions, sendEvent, triggerName
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class APICommandMultipleAttemptsTests: XCTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/ParseSwiftTests/APICommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class APICommandTests: XCTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down Expand Up @@ -126,7 +126,7 @@ class APICommandTests: XCTestCase {
func testSetServerURLOption() throws {
let serverURL1 = API.serverURL(options: [])
XCTAssertEqual(Parse.configuration.serverURL, serverURL1)
let newServerURLString = "http://parse:1337/1"
let newServerURLString = "http://parse:1337/parse"
let serverURL2 = API.serverURL(options: [.serverURL(newServerURLString)])
XCTAssertNotEqual(Parse.configuration.serverURL, serverURL2)
XCTAssertEqual(serverURL2, URL(string: newServerURLString))
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/ExtensionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import XCTest
class ExtensionsTests: XCTestCase {
override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/IOS13Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class IOS13Tests: XCTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
30 changes: 15 additions & 15 deletions Tests/ParseSwiftTests/InitializeSDKTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class InitializeSDKTests: XCTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down Expand Up @@ -153,7 +153,7 @@ class InitializeSDKTests: XCTestCase {
#endif

func testCreateParseInstallationOnInit() throws {
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down Expand Up @@ -219,7 +219,7 @@ class InitializeSDKTests: XCTestCase {
let expectation1 = XCTestExpectation(description: "Wait")
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {

guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
expectation1.fulfill()
return
Expand Down Expand Up @@ -265,7 +265,7 @@ class InitializeSDKTests: XCTestCase {
#endif

func testUpdateAuthChallenge() throws {
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand All @@ -284,7 +284,7 @@ class InitializeSDKTests: XCTestCase {

#if !os(Linux) && !os(Android) && !os(Windows)
func testDontOverwriteMigratedInstallation() throws {
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down Expand Up @@ -313,7 +313,7 @@ class InitializeSDKTests: XCTestCase {
}

func testDontOverwriteOldInstallationBecauseVersionLess() throws {
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down Expand Up @@ -349,7 +349,7 @@ class InitializeSDKTests: XCTestCase {
}

func testDontOverwriteOldInstallationBecauseVersionEqual() throws {
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down Expand Up @@ -385,7 +385,7 @@ class InitializeSDKTests: XCTestCase {
}

func testDontOverwriteOldInstallationBecauseVersionGreater() throws {
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down Expand Up @@ -423,7 +423,7 @@ class InitializeSDKTests: XCTestCase {
#endif

func testOverwriteOldInstallation() throws {
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down Expand Up @@ -457,7 +457,7 @@ class InitializeSDKTests: XCTestCase {
}

func testMigrateObjcKeychainMissing() throws {
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down Expand Up @@ -507,7 +507,7 @@ class InitializeSDKTests: XCTestCase {
try? KeychainStore.old.set(aclContainer, for: ParseStorage.Keys.defaultACL)
let expectation1 = XCTestExpectation(description: "Wait")
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
expectation1.fulfill()
return
Expand Down Expand Up @@ -539,7 +539,7 @@ class InitializeSDKTests: XCTestCase {
let objcInstallationId = "helloWorld"
_ = objcParseKeychain.setObjectiveC(object: objcInstallationId, forKey: "installationId")

guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand All @@ -560,7 +560,7 @@ class InitializeSDKTests: XCTestCase {
#if !os(macOS)
func testInitializeSDKNoTest() throws {

guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down Expand Up @@ -595,7 +595,7 @@ class InitializeSDKTests: XCTestCase {
XCTAssertNil(retrievedInstallationId2)

// This is needed for tear down
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand All @@ -616,7 +616,7 @@ class InitializeSDKTests: XCTestCase {
let objcInstallationId = "helloWorld"
_ = objcParseKeychain.setObjectiveC(object: objcInstallationId, forKey: "anotherPlace")

guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/KeychainStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class KeychainStoreTests: XCTestCase {
var testStore: KeychainStore!
override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/MigrateObjCSDKCombineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class MigrateObjCSDKCombineTests: XCTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/MigrateObjCSDKTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class MigrateObjCSDKTests: XCTestCase { // swiftlint:disable:this type_body_leng

override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/ParseACLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ParseACLTests: XCTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/ParseAnalyticsAsyncTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import XCTest
class ParseAnalyticsAsyncTests: XCTestCase {
override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/ParseAnalyticsCombineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ParseAnalyticsCombineTests: XCTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/ParseAnalyticsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ParseAnalyticsTests: XCTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/ParseAnonymousAsyncTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ParseAnonymousAsyncTests: XCTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/ParseAnonymousCombineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ParseAnonymousCombineTests: XCTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/ParseAnonymousTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ParseAnonymousTests: XCTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
guard let url = URL(string: "http://localhost:1337/1") else {
guard let url = URL(string: "http://localhost:1337/parse") else {
XCTFail("Should create valid URL")
return
}
Expand Down
Loading

0 comments on commit de696cc

Please sign in to comment.