Skip to content

Commit

Permalink
Cherry-pick pull request #1801
Browse files Browse the repository at this point in the history
`git cherry-pick -m1 d8c8a75`

Merge pull request #1801 from ably/fix/1764-preparation-for-macos-13

[SDK-3644] Preparation for macOS 13
  • Loading branch information
maratal authored and lawrence-forooghian committed Oct 31, 2023
1 parent 316dad5 commit 2a7ff98
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Cartfile.private
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "Quick/Nimble" == 9.2.1
github "Quick/Nimble" == 11.2.2
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "Quick/Nimble" "v9.2.1"
github "Quick/Nimble" "v11.2.2"
github "ably/delta-codec-cocoa" "1.3.3"
github "rvi/msgpack-objective-C" "0.4.0"
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ carthage_package:

# https://github.com/Carthage/Carthage#archive-prebuilt-frameworks-into-one-zip-file
# From `carthage help build` we are told that `--archive` implies `--no-skip-current`.
./Scripts/carthage-with-workaround-for-issue-3019.sh build --archive --no-use-binaries
./Scripts/carthage-with-workaround-for-issue-3019.sh build --archive --no-use-binaries --platform iOS,macOS,tvOS
# Add LICENSE files (ours and SocketRocket’s).
./Scripts/add-licenses-to-carthage-output.sh

Expand All @@ -105,7 +105,7 @@ carthage_clean:
update_carthage_dependencies:
$(info Updating Carthage dependencies for all platforms…)

carthage update --use-xcframeworks --no-use-binaries
carthage update --use-xcframeworks --platform iOS,macOS,tvOS --no-use-binaries

## [Carthage] Update dependencies for just iOS
update_carthage_dependencies_ios:
Expand Down
10 changes: 1 addition & 9 deletions Source/ARTRealtimePresence.m
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,7 @@ - (void)history:(ARTPaginatedPresenceCallback)callback {

- (BOOL)history:(ARTRealtimeHistoryQuery *)query callback:(ARTPaginatedPresenceCallback)callback error:(NSError **)errorPtr {
query.realtimeChannel = _channel;
@try {
return [_channel.restChannel.presence history:query callback:callback error:errorPtr];
}
@catch (NSError *error) {
if (errorPtr) {
*errorPtr = error;
}
return false;
}
return [_channel.restChannel.presence history:query callback:callback error:errorPtr];
}

- (void)enter:(id)data {
Expand Down
6 changes: 3 additions & 3 deletions Spec/Test Utilities/TestUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,7 @@ extension ARTPresenceAction : CustomStringConvertible {
// MARK: - Custom Nimble Matchers

/// A Nimble matcher that succeeds when two dates are quite the same.
public func beCloseTo(_ expectedValue: Date) -> Predicate<Date> {
public func beCloseTo(_ expectedValue: Date) -> Nimble.Predicate<Date> {
let errorMessage = "be close to <\(expectedValue)> (within 0.5)"
return Predicate.simple(errorMessage) { actualExpression in
guard let actualValue = try actualExpression.evaluate() else {
Expand All @@ -1712,7 +1712,7 @@ public func beCloseTo(_ expectedValue: Date) -> Predicate<Date> {
}

/// A Nimble matcher that succeeds when a param exists.
public func haveParam(_ key: String, withValue expectedValue: String? = nil) -> Predicate<String> {
public func haveParam(_ key: String, withValue expectedValue: String? = nil) -> Nimble.Predicate<String> {
let errorMessage = "param <\(key)=\(expectedValue ?? "nil")> exists"
return Predicate.simple(errorMessage) { actualExpression in
guard let actualValue = try actualExpression.evaluate() else {
Expand All @@ -1730,7 +1730,7 @@ public func haveParam(_ key: String, withValue expectedValue: String? = nil) ->
}

/// A Nimble matcher that succeeds when a param value starts with a particular string.
public func haveParam(_ key: String, hasPrefix expectedValue: String) -> Predicate<String> {
public func haveParam(_ key: String, hasPrefix expectedValue: String) -> Nimble.Predicate<String> {
let errorMessage = "param <\(key)> has prefix \(expectedValue)"
return Predicate.simple(errorMessage) { actualExpression in
guard let actualValue = try actualExpression.evaluate() else {
Expand Down
6 changes: 3 additions & 3 deletions Spec/Tests/AuthTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3671,9 +3671,9 @@ class AuthTests: XCTestCase {
realtime.auth.authorize(callback)
}

expect(didCancelAuthorization).to(be(true))
expect(realtime.auth.tokenDetails).to(beIdenticalTo(tokenDetailsLast))
expect(realtime.auth.tokenDetails?.token).to(equal(tokenDetailsLast?.token))
XCTAssertTrue(didCancelAuthorization)
XCTAssertTrue(realtime.auth.tokenDetails === tokenDetailsLast)
XCTAssertEqual(realtime.auth.tokenDetails?.token, tokenDetailsLast?.token)

if let transport = realtime.internal.transport as? TestProxyTransport, let query = transport.lastUrl?.query {
expect(query).to(haveParam("accessToken", withValue: realtime.auth.tokenDetails?.token ?? ""))
Expand Down
10 changes: 5 additions & 5 deletions Spec/Tests/RealtimeClientChannelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ class RealtimeClientChannelTests: XCTestCase {
}

expect(channel1.internal.presenceMap.members).toEventually(haveCount(2), timeout: testTimeout)
expect(channel1.internal.presenceMap.members.keys).to(allPass { $0!.hasPrefix("\(channel1.internal.connectionId):Client") || $0!.hasPrefix("\(channel2.internal.connectionId):Client") })
expect(channel1.internal.presenceMap.members.values).to(allPass { $0!.action == .present })
expect(channel1.internal.presenceMap.members.keys).to(allPass { $0.hasPrefix("\(channel1.internal.connectionId):Client") || $0.hasPrefix("\(channel2.internal.connectionId):Client") })
expect(channel1.internal.presenceMap.members.values).to(allPass { $0.action == .present })

expect(channel2.internal.presenceMap.members).toEventually(haveCount(2), timeout: testTimeout)
expect(channel2.internal.presenceMap.members.keys).to(allPass { $0!.hasPrefix("\(channel1.internal.connectionId):Client") || $0!.hasPrefix("\(channel2.internal.connectionId):Client") })
expect(channel2.internal.presenceMap.members["\(channel1.internal.connectionId):Client 1"]!.action).to(equal(ARTPresenceAction.present))
expect(channel2.internal.presenceMap.members["\(channel2.internal.connectionId):Client 2"]!.action).to(equal(ARTPresenceAction.present))
expect(channel2.internal.presenceMap.members.keys).to(allPass { $0.hasPrefix("\(channel1.internal.connectionId):Client") || $0.hasPrefix("\(channel2.internal.connectionId):Client") })
XCTAssertEqual(channel2.internal.presenceMap.members["\(channel1.internal.connectionId):Client 1"]!.action, ARTPresenceAction.present)
XCTAssertEqual(channel2.internal.presenceMap.members["\(channel2.internal.connectionId):Client 2"]!.action, ARTPresenceAction.present)
}

// RTL2
Expand Down
12 changes: 6 additions & 6 deletions Spec/Tests/RealtimeClientPresenceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3170,8 +3170,8 @@ class RealtimeClientPresenceTests: XCTestCase {
expect(members).to(haveCount(150))
expect(members!.first).to(beAnInstanceOf(ARTPresenceMessage.self))
expect(members).to(allPass { member in
NSRegularExpression.match(member!.clientId, pattern: "^user(\\d+)$")
&& (member!.data as? String) == expectedData
NSRegularExpression.match(member.clientId, pattern: "^user(\\d+)$")
&& (member.data as? String) == expectedData
})
done()
}
Expand Down Expand Up @@ -3664,8 +3664,8 @@ class RealtimeClientPresenceTests: XCTestCase {

let members = membersPage.items
expect(members).to(allPass { member in
NSRegularExpression.match(member!.clientId, pattern: expectedPattern)
&& (member!.data as! [String]) == expectedData
NSRegularExpression.match(member.clientId, pattern: expectedPattern)
&& (member.data as! [String]) == expectedData
})

expect(membersPage.hasNext).to(beTrue())
Expand All @@ -3681,8 +3681,8 @@ class RealtimeClientPresenceTests: XCTestCase {

let members = nextPage.items
expect(members).to(allPass { member in
NSRegularExpression.match(member!.clientId, pattern: expectedPattern)
&& (member!.data as! [String]) == expectedData
NSRegularExpression.match(member.clientId, pattern: expectedPattern)
&& (member.data as! [String]) == expectedData
})

expect(nextPage.hasNext).to(beFalse())
Expand Down
2 changes: 1 addition & 1 deletion Spec/Tests/RealtimeClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class RealtimeClientTests: XCTestCase {
/**
Test that replacing query string default values in ARTClientOptions works properly
*/
expect(absoluteString?.components(separatedBy: "v=").count).to(be(2))
XCTAssertEqual(absoluteString.components(separatedBy: "v=").count, 2)

done()
}
Expand Down
2 changes: 1 addition & 1 deletion Spec/Tests/RestClientChannelsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extension ARTRestChannels: Sequence {
}
}

private func beAChannel(named expectedValue: String) -> Predicate<ARTChannel> {
private func beAChannel(named expectedValue: String) -> Nimble.Predicate<ARTChannel> {
return Predicate.define("be a channel with name \"\(expectedValue)\"") { actualExpression, msg -> PredicateResult in
let actualValue = try! actualExpression.evaluate()
let m = msg.appended(details: "\"\(actualValue?.name ?? "nil")\" instead")
Expand Down
20 changes: 9 additions & 11 deletions Spec/Tests/RestClientPresenceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class RestClientPresenceTests: XCTestCase {

let members = membersPage.items
expect(members).to(allPass { member in
NSRegularExpression.match(member!.clientId, pattern: expectedPattern)
&& (member!.data as? String) == expectedData
NSRegularExpression.match(member.clientId, pattern: expectedPattern)
&& (member.data as? String) == expectedData
})

expect(membersPage.hasNext).to(beTrue())
Expand All @@ -51,8 +51,8 @@ class RestClientPresenceTests: XCTestCase {

let members = nextPage.items
expect(members).to(allPass { member in
NSRegularExpression.match(member!.clientId, pattern: expectedPattern)
&& (member!.data as? String) == expectedData
NSRegularExpression.match(member.clientId, pattern: expectedPattern)
&& (member.data as? String) == expectedData
})

expect(nextPage.hasNext).to(beFalse())
Expand Down Expand Up @@ -147,7 +147,6 @@ class RestClientPresenceTests: XCTestCase {
expect(membersPage!.hasNext).to(beFalse())
expect(membersPage!.isLast).to(beTrue())
expect(membersPage!.items).to(allPass { member in
let member = member!
return NSRegularExpression.match(member.clientId, pattern: "^user(7|8|9)")
})
done()
Expand Down Expand Up @@ -184,8 +183,8 @@ class RestClientPresenceTests: XCTestCase {

let members = membersPage.items
expect(members).to(allPass { member in
NSRegularExpression.match(member!.clientId, pattern: expectedPattern)
&& (member!.data as? String) == expectedData
NSRegularExpression.match(member.clientId, pattern: expectedPattern)
&& (member.data as? String) == expectedData
})

expect(membersPage.hasNext).to(beTrue())
Expand All @@ -201,8 +200,8 @@ class RestClientPresenceTests: XCTestCase {

let members = nextPage.items
expect(members).to(allPass { member in
NSRegularExpression.match(member!.clientId, pattern: expectedPattern)
&& (member!.data as? String) == expectedData
NSRegularExpression.match(member.clientId, pattern: expectedPattern)
&& (member.data as? String) == expectedData
})

expect(nextPage.hasNext).to(beFalse())
Expand Down Expand Up @@ -342,8 +341,7 @@ class RestClientPresenceTests: XCTestCase {
expect(membersPage!.hasNext).to(beFalse())
expect(membersPage!.isLast).to(beTrue())
expect(membersPage!.items).to(allPass { member in
let member = member
return NSRegularExpression.match(member!.clientId, pattern: "^user(7|8|9)")
return NSRegularExpression.match(member.clientId, pattern: "^user(7|8|9)")
})
done()
}
Expand Down
4 changes: 2 additions & 2 deletions Spec/Tests/RestClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,7 @@ class RestClientTests: XCTestCase {
$0.allHTTPHeaderFields!["Host"] == $0.url?.host
}

expect(fallbackRequests.count).to(be(fallbackRequestsWithHostHeader.count))
XCTAssertEqual(fallbackRequests.count, fallbackRequestsWithHostHeader.count)

afterEach__RestClient__Host_Fallback__retry_hosts_in_random_order()
}
Expand Down Expand Up @@ -2071,7 +2071,7 @@ class RestClientTests: XCTestCase {
}

expect(fallbackRequests).toNot(beEmpty())
expect(fallbackRequests).to(allPass { extractURLQueryValue($0?.url, key: "request_id") == requestId })
expect(fallbackRequests).to(allPass { extractURLQueryValue($0.url, key: "request_id") == requestId })
}

func test__097__RestClient__request_IDs__ErrorInfo_should_have__requestId__property() {
Expand Down

0 comments on commit 2a7ff98

Please sign in to comment.