Skip to content

Commit 8d33882

Browse files
authored
test(datastore): fix compiler errors in watchos unit tests due to missing disableSubscriptions arg (#3414)
1 parent 2a223e0 commit 8d33882

File tree

1 file changed

+36
-22
lines changed

1 file changed

+36
-22
lines changed

AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOperationTests.swift

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,22 @@ class InitialSyncOperationTests: XCTestCase {
2323
}
2424

2525
// MARK: - GetLastSyncTime
26-
26+
2727
func testFullSyncWhenLastSyncPredicateNilAndCurrentSyncPredicateNonNil() {
2828
let lastSyncTime: Int64 = 123456
2929
let lastSyncPredicate: String? = nil
3030
let currentSyncPredicate = DataStoreConfiguration.custom(
3131
syncExpressions: [
32-
.syncExpression(MockSynced.schema,
33-
where: { MockSynced.keys.id.eq("123")})])
32+
.syncExpression(
33+
MockSynced.schema,
34+
where: { MockSynced.keys.id.eq("123") }
35+
)
36+
],
37+
disableSubscriptions: { false }
38+
)
3439
let expectedSyncType = SyncType.fullSync
3540
let expectedLastSync: Int64? = nil
36-
41+
3742
let syncStartedReceived = expectation(description: "Sync started received, sync operation started")
3843
let operation = InitialSyncOperation(
3944
modelSchema: MockSynced.schema,
@@ -60,25 +65,24 @@ class InitialSyncOperationTests: XCTestCase {
6065
lastSync: lastSyncTime,
6166
syncPredicate: lastSyncPredicate)
6267
XCTAssertEqual(operation.getLastSyncTime(lastSyncMetadataLastSyncNil), expectedLastSync)
63-
68+
6469
waitForExpectations(timeout: 1)
6570
sink.cancel()
6671
}
67-
72+
6873
func testFullSyncWhenLastSyncPredicateNonNilAndCurrentSyncPredicateNil() {
6974
let lastSyncTime: Int64 = 123456
7075
let lastSyncPredicate: String? = "non nil"
71-
let currentSyncPredicate = DataStoreConfiguration.default
7276
let expectedSyncType = SyncType.fullSync
7377
let expectedLastSync: Int64? = nil
74-
78+
7579
let syncStartedReceived = expectation(description: "Sync started received, sync operation started")
7680
let operation = InitialSyncOperation(
7781
modelSchema: MockSynced.schema,
7882
api: nil,
7983
reconciliationQueue: nil,
8084
storageAdapter: nil,
81-
dataStoreConfiguration: currentSyncPredicate,
85+
dataStoreConfiguration: .custom(disableSubscriptions: { false }),
8286
authModeStrategy: AWSDefaultAuthModeStrategy())
8387
let sink = operation
8488
.publisher
@@ -98,21 +102,26 @@ class InitialSyncOperationTests: XCTestCase {
98102
lastSync: lastSyncTime,
99103
syncPredicate: lastSyncPredicate)
100104
XCTAssertEqual(operation.getLastSyncTime(lastSyncMetadataLastSyncNil), expectedLastSync)
101-
105+
102106
waitForExpectations(timeout: 1)
103107
sink.cancel()
104108
}
105-
109+
106110
func testFullSyncWhenLastSyncPredicateDifferentFromCurrentSyncPredicate() {
107111
let lastSyncTime: Int64 = 123456
108112
let lastSyncPredicate: String? = "non nil different from current predicate"
109113
let currentSyncPredicate = DataStoreConfiguration.custom(
110114
syncExpressions: [
111-
.syncExpression(MockSynced.schema,
112-
where: { MockSynced.keys.id.eq("123")})])
115+
.syncExpression(
116+
MockSynced.schema,
117+
where: { MockSynced.keys.id.eq("123") }
118+
)
119+
],
120+
disableSubscriptions: { false }
121+
)
113122
let expectedSyncType = SyncType.fullSync
114123
let expectedLastSync: Int64? = nil
115-
124+
116125
let syncStartedReceived = expectation(description: "Sync started received, sync operation started")
117126
let operation = InitialSyncOperation(
118127
modelSchema: MockSynced.schema,
@@ -139,22 +148,27 @@ class InitialSyncOperationTests: XCTestCase {
139148
lastSync: lastSyncTime,
140149
syncPredicate: lastSyncPredicate)
141150
XCTAssertEqual(operation.getLastSyncTime(lastSyncMetadataLastSyncNil), expectedLastSync)
142-
151+
143152
waitForExpectations(timeout: 1)
144153
sink.cancel()
145154
}
146-
155+
147156
func testDeltaSyncWhenLastSyncPredicateSameAsCurrentSyncPredicate() {
148157
let startDateSeconds = (Int64(Date().timeIntervalSince1970) - 100)
149158
let lastSyncTime: Int64 = startDateSeconds * 1_000
150159
let lastSyncPredicate: String? = "{\"field\":\"id\",\"operator\":{\"type\":\"equals\",\"value\":\"123\"}}"
151160
let currentSyncPredicate = DataStoreConfiguration.custom(
152161
syncExpressions: [
153-
.syncExpression(MockSynced.schema,
154-
where: { MockSynced.keys.id.eq("123")})])
162+
.syncExpression(
163+
MockSynced.schema,
164+
where: { MockSynced.keys.id.eq("123") }
165+
)
166+
],
167+
disableSubscriptions: { false }
168+
)
155169
let expectedSyncType = SyncType.deltaSync
156170
let expectedLastSync: Int64? = lastSyncTime
157-
171+
158172
let syncStartedReceived = expectation(description: "Sync started received, sync operation started")
159173
let operation = InitialSyncOperation(
160174
modelSchema: MockSynced.schema,
@@ -181,13 +195,13 @@ class InitialSyncOperationTests: XCTestCase {
181195
lastSync: lastSyncTime,
182196
syncPredicate: lastSyncPredicate)
183197
XCTAssertEqual(operation.getLastSyncTime(lastSyncMetadataLastSyncNil), expectedLastSync)
184-
198+
185199
waitForExpectations(timeout: 1)
186200
sink.cancel()
187201
}
188-
202+
189203
// MARK: - `main()` tests
190-
204+
191205
/// - Given: An InitialSyncOperation
192206
/// - When:
193207
/// - I invoke main()

0 commit comments

Comments
 (0)