Skip to content

Commit

Permalink
test(datastore): add watchos checks to initialsync test cases for dis…
Browse files Browse the repository at this point in the history
…ableSubscriptions
  • Loading branch information
atierian committed Dec 11, 2023
1 parent 8d33882 commit cfb816e
Showing 1 changed file with 43 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class InitialSyncOperationTests: XCTestCase {
func testFullSyncWhenLastSyncPredicateNilAndCurrentSyncPredicateNonNil() {
let lastSyncTime: Int64 = 123456
let lastSyncPredicate: String? = nil
let currentSyncPredicate = DataStoreConfiguration.custom(
let currentSyncPredicate: DataStoreConfiguration
#if os(watchOS)
currentSyncPredicate = DataStoreConfiguration.custom(
syncExpressions: [
.syncExpression(
MockSynced.schema,
Expand All @@ -36,6 +38,17 @@ class InitialSyncOperationTests: XCTestCase {
],
disableSubscriptions: { false }
)
#else
currentSyncPredicate = DataStoreConfiguration.custom(
syncExpressions: [
.syncExpression(
MockSynced.schema,
where: { MockSynced.keys.id.eq("123") }
)
]
)
#endif

let expectedSyncType = SyncType.fullSync
let expectedLastSync: Int64? = nil

Expand Down Expand Up @@ -82,7 +95,7 @@ class InitialSyncOperationTests: XCTestCase {
api: nil,
reconciliationQueue: nil,
storageAdapter: nil,
dataStoreConfiguration: .custom(disableSubscriptions: { false }),
dataStoreConfiguration: .testDefault(),
authModeStrategy: AWSDefaultAuthModeStrategy())
let sink = operation
.publisher
Expand Down Expand Up @@ -110,7 +123,9 @@ class InitialSyncOperationTests: XCTestCase {
func testFullSyncWhenLastSyncPredicateDifferentFromCurrentSyncPredicate() {
let lastSyncTime: Int64 = 123456
let lastSyncPredicate: String? = "non nil different from current predicate"
let currentSyncPredicate = DataStoreConfiguration.custom(
let currentSyncPredicate: DataStoreConfiguration
#if os(watchOS)
currentSyncPredicate = DataStoreConfiguration.custom(
syncExpressions: [
.syncExpression(
MockSynced.schema,
Expand All @@ -119,6 +134,17 @@ class InitialSyncOperationTests: XCTestCase {
],
disableSubscriptions: { false }
)
#else
currentSyncPredicate = DataStoreConfiguration.custom(
syncExpressions: [
.syncExpression(
MockSynced.schema,
where: { MockSynced.keys.id.eq("123") }
)
]
)
#endif

let expectedSyncType = SyncType.fullSync
let expectedLastSync: Int64? = nil

Expand Down Expand Up @@ -157,7 +183,9 @@ class InitialSyncOperationTests: XCTestCase {
let startDateSeconds = (Int64(Date().timeIntervalSince1970) - 100)
let lastSyncTime: Int64 = startDateSeconds * 1_000
let lastSyncPredicate: String? = "{\"field\":\"id\",\"operator\":{\"type\":\"equals\",\"value\":\"123\"}}"
let currentSyncPredicate = DataStoreConfiguration.custom(
let currentSyncPredicate: DataStoreConfiguration
#if os(watchOS)
currentSyncPredicate = DataStoreConfiguration.custom(
syncExpressions: [
.syncExpression(
MockSynced.schema,
Expand All @@ -166,6 +194,17 @@ class InitialSyncOperationTests: XCTestCase {
],
disableSubscriptions: { false }
)
#else
currentSyncPredicate = DataStoreConfiguration.custom(
syncExpressions: [
.syncExpression(
MockSynced.schema,
where: { MockSynced.keys.id.eq("123") }
)
]
)
#endif

let expectedSyncType = SyncType.deltaSync
let expectedLastSync: Int64? = lastSyncTime

Expand Down

0 comments on commit cfb816e

Please sign in to comment.