Skip to content

Commit 2166510

Browse files
authored
test(datastore): add watchos checks to initialsync test cases for disableSubscriptions (#3416)
1 parent 8d33882 commit 2166510

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

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

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ class InitialSyncOperationTests: XCTestCase {
2727
func testFullSyncWhenLastSyncPredicateNilAndCurrentSyncPredicateNonNil() {
2828
let lastSyncTime: Int64 = 123456
2929
let lastSyncPredicate: String? = nil
30-
let currentSyncPredicate = DataStoreConfiguration.custom(
30+
let currentSyncPredicate: DataStoreConfiguration
31+
#if os(watchOS)
32+
currentSyncPredicate = DataStoreConfiguration.custom(
3133
syncExpressions: [
3234
.syncExpression(
3335
MockSynced.schema,
@@ -36,6 +38,17 @@ class InitialSyncOperationTests: XCTestCase {
3638
],
3739
disableSubscriptions: { false }
3840
)
41+
#else
42+
currentSyncPredicate = DataStoreConfiguration.custom(
43+
syncExpressions: [
44+
.syncExpression(
45+
MockSynced.schema,
46+
where: { MockSynced.keys.id.eq("123") }
47+
)
48+
]
49+
)
50+
#endif
51+
3952
let expectedSyncType = SyncType.fullSync
4053
let expectedLastSync: Int64? = nil
4154

@@ -82,7 +95,7 @@ class InitialSyncOperationTests: XCTestCase {
8295
api: nil,
8396
reconciliationQueue: nil,
8497
storageAdapter: nil,
85-
dataStoreConfiguration: .custom(disableSubscriptions: { false }),
98+
dataStoreConfiguration: .testDefault(),
8699
authModeStrategy: AWSDefaultAuthModeStrategy())
87100
let sink = operation
88101
.publisher
@@ -110,7 +123,9 @@ class InitialSyncOperationTests: XCTestCase {
110123
func testFullSyncWhenLastSyncPredicateDifferentFromCurrentSyncPredicate() {
111124
let lastSyncTime: Int64 = 123456
112125
let lastSyncPredicate: String? = "non nil different from current predicate"
113-
let currentSyncPredicate = DataStoreConfiguration.custom(
126+
let currentSyncPredicate: DataStoreConfiguration
127+
#if os(watchOS)
128+
currentSyncPredicate = DataStoreConfiguration.custom(
114129
syncExpressions: [
115130
.syncExpression(
116131
MockSynced.schema,
@@ -119,6 +134,17 @@ class InitialSyncOperationTests: XCTestCase {
119134
],
120135
disableSubscriptions: { false }
121136
)
137+
#else
138+
currentSyncPredicate = DataStoreConfiguration.custom(
139+
syncExpressions: [
140+
.syncExpression(
141+
MockSynced.schema,
142+
where: { MockSynced.keys.id.eq("123") }
143+
)
144+
]
145+
)
146+
#endif
147+
122148
let expectedSyncType = SyncType.fullSync
123149
let expectedLastSync: Int64? = nil
124150

@@ -157,7 +183,9 @@ class InitialSyncOperationTests: XCTestCase {
157183
let startDateSeconds = (Int64(Date().timeIntervalSince1970) - 100)
158184
let lastSyncTime: Int64 = startDateSeconds * 1_000
159185
let lastSyncPredicate: String? = "{\"field\":\"id\",\"operator\":{\"type\":\"equals\",\"value\":\"123\"}}"
160-
let currentSyncPredicate = DataStoreConfiguration.custom(
186+
let currentSyncPredicate: DataStoreConfiguration
187+
#if os(watchOS)
188+
currentSyncPredicate = DataStoreConfiguration.custom(
161189
syncExpressions: [
162190
.syncExpression(
163191
MockSynced.schema,
@@ -166,6 +194,17 @@ class InitialSyncOperationTests: XCTestCase {
166194
],
167195
disableSubscriptions: { false }
168196
)
197+
#else
198+
currentSyncPredicate = DataStoreConfiguration.custom(
199+
syncExpressions: [
200+
.syncExpression(
201+
MockSynced.schema,
202+
where: { MockSynced.keys.id.eq("123") }
203+
)
204+
]
205+
)
206+
#endif
207+
169208
let expectedSyncType = SyncType.deltaSync
170209
let expectedLastSync: Int64? = lastSyncTime
171210

0 commit comments

Comments
 (0)