Skip to content

Commit ed08223

Browse files
Extract integration tests helper
Will use in some upcoming tests for object lifetimes.
1 parent 2a0b3a2 commit ed08223

1 file changed

Lines changed: 6 additions & 27 deletions

File tree

Tests/AblyLiveObjectsTests/JS Integration Tests/ObjectsIntegrationTests.swift

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,12 @@ import Testing
99

1010
// MARK: - Top-level helpers
1111

12-
private func realtimeWithObjects(options: PartialClientOptions = .init()) async throws -> ARTRealtime {
13-
let key = try await Sandbox.fetchSharedAPIKey()
14-
let clientOptions = ARTClientOptions(key: key)
15-
clientOptions.plugins = [.liveObjects: AblyLiveObjects.Plugin.self]
16-
clientOptions.environment = "sandbox"
17-
18-
clientOptions.testOptions.transportFactory = TestProxyTransportFactory()
19-
20-
if TestLogger.loggingEnabled {
21-
clientOptions.logLevel = .verbose
22-
}
23-
24-
if let useBinaryProtocol = options.useBinaryProtocol {
25-
clientOptions.useBinaryProtocol = useBinaryProtocol
26-
}
27-
28-
return ARTRealtime(options: clientOptions)
12+
private func realtimeWithObjects(options: ClientHelper.PartialClientOptions) async throws -> ARTRealtime {
13+
try await ClientHelper.realtimeWithObjects(options: options)
2914
}
3015

3116
private func channelOptionsWithObjects() -> ARTRealtimeChannelOptions {
32-
let options = ARTRealtimeChannelOptions()
33-
options.modes = [.objectSubscribe, .objectPublish]
34-
return options
17+
ClientHelper.channelOptionsWithObjects()
3518
}
3619

3720
// Swift version of the JS lexicoTimeserial function
@@ -152,7 +135,7 @@ private let objectsFixturesChannel = "objects_fixtures"
152135
private struct TestCase<Context>: Identifiable, CustomStringConvertible {
153136
var disabled: Bool
154137
var scenario: TestScenario<Context>
155-
var options: PartialClientOptions
138+
var options: ClientHelper.PartialClientOptions
156139
var channelName: String
157140

158141
/// This `Identifiable` conformance allows us to re-run individual test cases from the Xcode UI (https://developer.apple.com/documentation/testing/parameterizedtesting#Run-selected-test-cases)
@@ -175,11 +158,7 @@ private struct TestCase<Context>: Identifiable, CustomStringConvertible {
175158
/// Enables `TestCase`'s conformance to `Identifiable`.
176159
private struct TestCaseID: Encodable, Hashable {
177160
var description: String
178-
var options: PartialClientOptions?
179-
}
180-
181-
private struct PartialClientOptions: Encodable, Hashable {
182-
var useBinaryProtocol: Bool?
161+
var options: ClientHelper.PartialClientOptions?
183162
}
184163

185164
/// The input to `forScenarios`.
@@ -268,7 +247,7 @@ private struct ObjectsIntegrationTests {
268247
var channelName: String
269248
var channel: ARTRealtimeChannel
270249
var client: ARTRealtime
271-
var clientOptions: PartialClientOptions
250+
var clientOptions: ClientHelper.PartialClientOptions
272251
}
273252

274253
static let scenarios: [TestScenario<Context>] = {

0 commit comments

Comments
 (0)