Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Parse-Swift Changelog

### main
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.9.2...main)
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.9.3...main)
* _Contributing to this repo? Add info about your change here to be included in the next release_

### 1.9.3
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.9.2...1.9.3)
__Improvements__
- Ensure delegate set before resuming a ParseLiveQuery task ([#209](https://github.com/parse-community/Parse-Swift/pull/209)), thanks to [Corey Baker](https://github.com/cbaker6).

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 = "1.9.2"
static let version = "1.9.3"
static let fileManagementDirectory = "parse/"
static let fileManagementPrivateDocumentsDirectory = "Private Documents/"
static let fileManagementLibraryDirectory = "Library/"
Expand Down
58 changes: 16 additions & 42 deletions Tests/ParseSwiftTests/ParseLiveQueryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class ParseLiveQueryTests: XCTestCase {
try KeychainStore.shared.deleteAll()
#endif
try ParseStorage.shared.deleteAll()
URLSession.liveQuery.closeAll()
}

func testWebsocketURL() throws {
Expand All @@ -89,10 +90,9 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertTrue(client.url.absoluteString.contains("ws"))

let expectation1 = XCTestExpectation(description: "Socket delegate")
client.synchronizationQueue.async {
client.synchronizationQueue.asyncAfter(deadline: .now() + 2) {
let socketDelegates = URLSession.liveQuery.delegates
XCTAssertNotNil(socketDelegates[client.task])
client.close()
expectation1.fulfill()
}
wait(for: [expectation1], timeout: 20.0)
Expand All @@ -118,10 +118,9 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertTrue(client.url.absoluteString.contains("ws"))
XCTAssertNotEqual(client, defaultClient)
let expectation1 = XCTestExpectation(description: "Socket delegate")
client.synchronizationQueue.async {
client.synchronizationQueue.asyncAfter(deadline: .now() + 2) {
let socketDelegates = URLSession.liveQuery.delegates
XCTAssertNotNil(socketDelegates[client.task])
client.close()
expectation1.fulfill()
}
wait(for: [expectation1], timeout: 20.0)
Expand All @@ -138,10 +137,9 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertTrue(client.url.absoluteString.contains("ws"))
XCTAssertEqual(client, defaultClient)
let expectation1 = XCTestExpectation(description: "Socket delegate")
client.synchronizationQueue.async {
client.synchronizationQueue.asyncAfter(deadline: .now() + 2) {
let socketDelegates = URLSession.liveQuery.delegates
XCTAssertNotNil(socketDelegates[client.task])
client.close()
expectation1.fulfill()
}
wait(for: [expectation1], timeout: 20.0)
Expand All @@ -162,10 +160,9 @@ class ParseLiveQueryTests: XCTestCase {
client = nil
XCTAssertNotNil(ParseLiveQuery.getDefault())
let expectation1 = XCTestExpectation(description: "Socket delegate")
defaultClient.synchronizationQueue.async {
defaultClient.synchronizationQueue.asyncAfter(deadline: .now() + 2) {
let socketDelegates = URLSession.liveQuery.delegates
XCTAssertNotNil(socketDelegates[defaultClient.task])
defaultClient.close()
expectation1.fulfill()
}
wait(for: [expectation1], timeout: 20.0)
Expand All @@ -189,7 +186,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertNotNil(URLSession.liveQuery.authenticationDelegate)
client.authenticationDelegate = nil
XCTAssertNil(URLSession.liveQuery.authenticationDelegate)
client.close()
}

func testStandardMessageEncoding() throws {
Expand Down Expand Up @@ -324,7 +320,6 @@ class ParseLiveQueryTests: XCTestCase {
client.isConnected = true
XCTAssertEqual(client.isConnecting, false)
XCTAssertEqual(client.isConnected, false)
client.close()
}

func testConnectedState() throws {
Expand Down Expand Up @@ -356,7 +351,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertEqual(client.isConnecting, false)
XCTAssertEqual(client.clientId, "yolo")
XCTAssertEqual(client.attempts, ParseLiveQueryConstants.maxConnectionAttempts + 1)
client.close()
}

func testDisconnectedState() throws {
Expand All @@ -378,7 +372,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertEqual(client.isConnected, false)
XCTAssertEqual(client.isConnecting, false)
XCTAssertNil(client.clientId)
client.close()
}

func testSocketDisconnectedState() throws {
Expand All @@ -399,7 +392,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertEqual(client.isConnected, false)
XCTAssertEqual(client.isConnecting, false)
XCTAssertNil(client.clientId)
client.close()
}

func testUserClosedConnectionState() throws {
Expand All @@ -424,7 +416,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertEqual(client.isConnecting, false)
XCTAssertNil(client.clientId)
XCTAssertEqual(client.isDisconnectedByUser, true)
client.close()
}

func testOpenSocket() throws {
Expand All @@ -437,7 +428,6 @@ class ParseLiveQueryTests: XCTestCase {
client.open(isUserWantsToConnect: true) { error in
XCTAssertNotNil(error) //Should always fail since WS isn't intercepted.
expectation1.fulfill()
client.close()
}
wait(for: [expectation1], timeout: 20.0)
}
Expand All @@ -457,7 +447,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertEqual(delegate.code, .goingAway)
XCTAssertNil(delegate.reason)
XCTAssertTrue(client.task.state == .completed)
client.close()
expectation1.fulfill()
}
wait(for: [expectation1], timeout: 20.0)
Expand Down Expand Up @@ -526,11 +515,21 @@ class ParseLiveQueryTests: XCTestCase {

func testCloseAll() throws {
let client = try ParseLiveQuery()
guard let originalTask = client.task else {
XCTFail("Should not be nil")
return
}
XCTAssertTrue(client.task.state == .running)
client.isSocketEstablished = true
client.isConnected = true
client.closeAll()
let expectation1 = XCTestExpectation(description: "Close all")
client.synchronizationQueue.asyncAfter(deadline: .now() + 2) {
XCTAssertTrue(client.task.state == .suspended)
XCTAssertFalse(client.isSocketEstablished)
XCTAssertFalse(client.isConnected)
XCTAssertNil(URLSession.liveQuery.delegates[originalTask])
XCTAssertNotNil(URLSession.liveQuery.delegates[client.task])
expectation1.fulfill()
}
wait(for: [expectation1], timeout: 20.0)
Expand All @@ -552,7 +551,6 @@ class ParseLiveQueryTests: XCTestCase {
}
XCTAssertEqual(parseError.code, ParseError.Code.unknownError)
XCTAssertTrue(parseError.message.contains("socket status"))
client.close()
expectation1.fulfill()
}
wait(for: [expectation1], timeout: 20.0)
Expand All @@ -572,7 +570,6 @@ class ParseLiveQueryTests: XCTestCase {
client.sendPing { error in
XCTAssertEqual(client.isSocketEstablished, true)
XCTAssertNotNil(error) // Should have error because testcases don't intercept websocket
client.close()
expectation1.fulfill()
}
wait(for: [expectation1], timeout: 20.0)
Expand All @@ -589,7 +586,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertGreaterThan(time, -1)
client.attempts += index
}
client.close()
}

func testRandomIdGenerator() throws {
Expand All @@ -601,7 +597,6 @@ class ParseLiveQueryTests: XCTestCase {
let idGenerated = client.requestIdGenerator()
XCTAssertEqual(idGenerated.value, index)
}
client.close()
}

func testSubscribeNotConnected() throws {
Expand All @@ -621,7 +616,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertEqual(client.pendingSubscriptions.count, 1)
XCTAssertNoThrow(try client.removePendingSubscription(query))
XCTAssertEqual(client.pendingSubscriptions.count, 0)
client.close()
}

func pretendToBeConnected() throws {
Expand Down Expand Up @@ -675,7 +669,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertEqual(query, unsubscribed)
XCTAssertNil(subscription.subscribed)
XCTAssertNil(subscription.event)
client.close()
expectation2.fulfill()
}

Expand Down Expand Up @@ -742,7 +735,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertTrue(client.pendingSubscriptions.isEmpty)
XCTAssertTrue(client.subscriptions.isEmpty)
XCTAssertFalse(client.isSocketEstablished)
client.close()
expectation2.fulfill()
}
XCTAssertNotNil(try? query.unsubscribe())
Expand Down Expand Up @@ -810,7 +802,6 @@ class ParseLiveQueryTests: XCTestCase {
} else {
XCTAssertNotNil(ParseLiveQuery.client?.task)
XCTAssertFalse(originalTask == ParseLiveQuery.client?.task)
client.close()
expectation2.fulfill()
return
}
Expand Down Expand Up @@ -883,7 +874,6 @@ class ParseLiveQueryTests: XCTestCase {
let encoded = try ParseCoding.jsonEncoder().encode(response)
client.received(encoded)
XCTAssertEqual(client.url, url)
client.close()
}

func testServerErrorResponse() throws {
Expand All @@ -908,7 +898,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertNotNil(delegate.error)
XCTAssertEqual(delegate.error?.code, ParseError.Code.internalServer)
XCTAssertTrue(delegate.error?.message.contains("message") != nil)
client.close()
expectation1.fulfill()
}
wait(for: [expectation1], timeout: 20.0)
Expand Down Expand Up @@ -939,11 +928,10 @@ class ParseLiveQueryTests: XCTestCase {
expectation1.fulfill()
}
let expectation2 = XCTestExpectation(description: "Client closed")
client.synchronizationQueue.async {
client.synchronizationQueue.asyncAfter(deadline: .now() + 2) {
XCTAssertTrue(client.isDisconnectedByUser)
XCTAssertFalse(client.isConnected)
XCTAssertFalse(client.isConnecting)
client.close()
expectation2.fulfill()
}
wait(for: [expectation1, expectation2], timeout: 20.0)
Expand Down Expand Up @@ -980,7 +968,6 @@ class ParseLiveQueryTests: XCTestCase {
default:
XCTFail("Should have receeived event")
}
client.close()
expectation1.fulfill()
}

Expand Down Expand Up @@ -1033,7 +1020,6 @@ class ParseLiveQueryTests: XCTestCase {
default:
XCTFail("Should have receeived event")
}
client.close()
expectation1.fulfill()
}

Expand Down Expand Up @@ -1086,7 +1072,6 @@ class ParseLiveQueryTests: XCTestCase {
default:
XCTFail("Should have receeived event")
}
client.close()
expectation1.fulfill()
}

Expand Down Expand Up @@ -1139,7 +1124,6 @@ class ParseLiveQueryTests: XCTestCase {
default:
XCTFail("Should have receeived event")
}
client.close()
expectation1.fulfill()
}

Expand Down Expand Up @@ -1192,7 +1176,6 @@ class ParseLiveQueryTests: XCTestCase {
default:
XCTFail("Should have receeived event")
}
client.close()
expectation1.fulfill()
}

Expand Down Expand Up @@ -1257,7 +1240,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertFalse(subscribed.isNew)
XCTAssertEqual(client.subscriptions.count, 1)
XCTAssertEqual(client.pendingSubscriptions.count, 0)
client.close()
expectation2.fulfill()
return
}
Expand Down Expand Up @@ -1356,7 +1338,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertNil(subscription.unsubscribed)
XCTAssertEqual(client.subscriptions.count, 1)
XCTAssertEqual(client.pendingSubscriptions.count, 0)
client.close()
expectation2.fulfill()
return
}
Expand Down Expand Up @@ -1414,7 +1395,6 @@ class ParseLiveQueryTests: XCTestCase {
default:
XCTFail("Should have receeived event")
}
client.close()
expectation1.fulfill()
}

Expand Down Expand Up @@ -1458,7 +1438,6 @@ class ParseLiveQueryTests: XCTestCase {
default:
XCTFail("Should have receeived event")
}
client.close()
expectation1.fulfill()
}

Expand Down Expand Up @@ -1502,7 +1481,6 @@ class ParseLiveQueryTests: XCTestCase {
default:
XCTFail("Should have receeived event")
}
client.close()
expectation1.fulfill()
}

Expand Down Expand Up @@ -1546,7 +1524,6 @@ class ParseLiveQueryTests: XCTestCase {
default:
XCTFail("Should have receeived event")
}
client.close()
expectation1.fulfill()
}

Expand Down Expand Up @@ -1590,7 +1567,6 @@ class ParseLiveQueryTests: XCTestCase {
default:
XCTFail("Should have receeived event")
}
client.close()
expectation1.fulfill()
}

Expand Down Expand Up @@ -1635,7 +1611,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertFalse(isNew)
XCTAssertEqual(client.subscriptions.count, 1)
XCTAssertEqual(client.pendingSubscriptions.count, 0)
client.close()
expectation2.fulfill()
return
}
Expand Down Expand Up @@ -1706,7 +1681,6 @@ class ParseLiveQueryTests: XCTestCase {
XCTAssertTrue(isNew)
XCTAssertEqual(client.subscriptions.count, 1)
XCTAssertEqual(client.pendingSubscriptions.count, 0)
client.close()
expectation2.fulfill()
return
}
Expand Down