From 459aaed09f7dfb9c35fc28d5c204dfa20a05c76e Mon Sep 17 00:00:00 2001 From: Michael Law <1365977+lawmicha@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:32:44 -0500 Subject: [PATCH] feat(DataStore): DisableSubscriptions flag for watchOS (#3368) * fix(DataStore): Store larger than 32-bit values in Int64 over Int * fix: Removing ModelFieldType.int64 * feat(DataStore): DisableSubscriptions flag for watchOS * fix 'default' DataStoreConfiguration to non-watchOS. introduce 'testDefault' for shared testing. force plugin initializer to take in configuration for watchOS * move integration tests under watchOS flag * fix integration tests code * fix integration test code * Add verbose logging when subsriptions enabled, watchOS simulator * add doc comments --- .../AWSCloudWatchLoggingPlugin.xcscheme | 2 +- .../AWSDataStorePlugin.swift | 37 ++++++++- .../DataStoreConfiguration+Helper.swift | 62 ++++++++++++++- .../DataStoreConfiguration.swift | 24 +++++- .../Sync/RemoteSyncEngine.swift | 5 +- .../AWSIncomingEventReconciliationQueue.swift | 50 ++++++++---- ...onDisabledSubscriptionEventPublisher.swift | 31 ++++++++ .../AWSModelReconciliationQueue.swift | 11 ++- ...taStorePluginAmplifyVersionableTests.swift | 5 ++ .../DataStoreCategoryConfigurationTests.swift | 6 ++ .../SQLiteStorageEngineAdapterJsonTests.swift | 4 +- .../Storage/CascadeDeleteOperationTests.swift | 2 +- .../Storage/StorageEnginePublisherTests.swift | 2 +- .../Storage/StorageEngineTestsDelete.swift | 2 +- .../Storage/StorageEngineTestsHasMany.swift | 2 +- .../Storage/StorageEngineTestsHasOne.swift | 2 +- ...geEngineTestsLazyPostComment4V2Tests.swift | 2 +- .../StorageEngineTestsManyToMany.swift | 2 +- ...torageEngineTestsOptionalAssociation.swift | 2 +- ...torageEngineTestsPostComment4V2Tests.swift | 2 +- .../StorageEngineTestsSQLiteIndex.swift | 2 +- .../ObserveQueryTaskRunnerTests.swift | 22 +++--- .../Sync/APICategoryDependencyTests.swift | 4 +- ...tialSyncOperationSyncExpressionTests.swift | 9 ++- .../InitialSyncOperationTests.swift | 42 ++++++++-- .../InitialSyncOrchestratorTests.swift | 12 +-- .../ModelSyncedEventEmitterTests.swift | 2 +- .../InitialSync/SyncEventEmitterTests.swift | 6 +- .../Sync/LocalSubscriptionTests.swift | 4 +- .../LocalSubscriptionWithJSONModelTests.swift | 4 +- .../AWSMutationEventIngesterTests.swift | 4 +- .../OutgoingMutationQueueNetworkTests.swift | 2 +- .../OutgoingMutationQueueTests.swift | 4 +- ...tationQueueTestsWithMockStateMachine.swift | 4 +- ...MutationErrorFromCloudOperationTests.swift | 71 ++++++++++++----- .../RemoteSyncAPIInvocationTests.swift | 4 +- .../Sync/RemoteSyncEngineTests.swift | 2 +- .../TestSupport/BaseDataStoreTests.swift | 4 +- .../LocalStoreIntegrationTestBase.swift | 5 ++ ...kAWSIncomingEventReconciliationQueue.swift | 2 +- .../TestSupport/SyncEngineTestBase.swift | 4 +- .../AWSDataStoreAuthBaseTest.swift | 5 +- .../AWSDataStoreAuthBaseTest.swift | 5 +- .../11/AWSDataStoreIntSortKeyTest.swift | 7 ++ .../12/AWSDataStoreFloatSortKeyTest.swift | 7 ++ .../13/AWSDataStoreDateTimeSortKeyTest.swift | 7 ++ .../14/AWSDataStoreDateSortKeyTest.swift | 7 ++ .../15/AWSDataStoreTimeSortKeyTest.swift | 7 ++ ...aStoreCompositeSortKeyIdentifierTest.swift | 7 ++ .../AWSDataStorePrimaryKeyBaseTest.swift | 7 ++ .../AWSDataStoreSortKeyBaseTest.swift | 7 ++ ...AWSDataStorePluginConfigurationTests.swift | 4 + ...toreConnectionScenario1Tests+WatchOS.swift | 77 +++++++++++++++++++ .../DataStoreConnectionScenario1Tests.swift | 4 +- .../DataStoreConfigurationTests.swift | 16 ++++ .../DataStoreEndToEndTests.swift | 7 ++ .../DataStoreObserveQueryTests.swift | 30 +++++--- .../HubEventsIntegrationTestBase.swift | 4 + .../SyncEngineIntegrationTestBase.swift | 9 +++ .../AWSDataStoreLazyLoadBaseTest.swift | 10 +++ .../AWSDataStoreAuthBaseTest.swift | 6 +- .../SyncEngineIntegrationV2TestBase.swift | 5 ++ .../project.pbxproj | 4 + 63 files changed, 585 insertions(+), 125 deletions(-) create mode 100644 AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/SubscriptionSync/OperationDisabledSubscriptionEventPublisher.swift create mode 100644 AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/Connection/DataStoreConnectionScenario1Tests+WatchOS.swift diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/AWSCloudWatchLoggingPlugin.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/AWSCloudWatchLoggingPlugin.xcscheme index 29ec3fca31..ce4dcb87b8 100644 --- a/.swiftpm/xcode/xcshareddata/xcschemes/AWSCloudWatchLoggingPlugin.xcscheme +++ b/.swiftpm/xcode/xcshareddata/xcschemes/AWSCloudWatchLoggingPlugin.xcscheme @@ -1,7 +1,7 @@ + version = "1.3"> diff --git a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/AWSDataStorePlugin.swift b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/AWSDataStorePlugin.swift index c929c872fe..5f775a0e69 100644 --- a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/AWSDataStorePlugin.swift +++ b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/AWSDataStorePlugin.swift @@ -55,9 +55,13 @@ final public class AWSDataStorePlugin: DataStoreCategoryPlugin { } } - /// No-argument init that uses defaults for all providers + #if os(watchOS) + /// Initializer + /// - Parameters: + /// - modelRegistration: Register DataStore models. + /// - dataStoreConfiguration: Configuration object for DataStore public init(modelRegistration: AmplifyModelRegistration, - configuration dataStoreConfiguration: DataStoreConfiguration = .default) { + configuration dataStoreConfiguration: DataStoreConfiguration) { self.modelRegistration = modelRegistration self.configuration = InternalDatastoreConfiguration( isSyncEnabled: false, @@ -77,10 +81,37 @@ final public class AWSDataStorePlugin: DataStoreCategoryPlugin { self.dataStorePublisher = DataStorePublisher() self.dispatchedModelSyncedEvents = [:] } + #else + /// Initializer + /// - Parameters: + /// - modelRegistration: Register DataStore models. + /// - dataStoreConfiguration: Configuration object for DataStore + public init(modelRegistration: AmplifyModelRegistration, + configuration dataStoreConfiguration: DataStoreConfiguration = .default) { + self.modelRegistration = modelRegistration + self.configuration = InternalDatastoreConfiguration( + isSyncEnabled: false, + validAPIPluginKey: "awsAPIPlugin", + validAuthPluginKey: "awsCognitoAuthPlugin", + pluginConfiguration: dataStoreConfiguration) + self.storageEngineBehaviorFactory = + StorageEngine.init( + isSyncEnabled: + dataStoreConfiguration: + validAPIPluginKey: + validAuthPluginKey: + modelRegistryVersion: + userDefault: + ) + self.dataStorePublisher = DataStorePublisher() + self.dispatchedModelSyncedEvents = [:] + } + #endif + /// Internal initializer for testing init(modelRegistration: AmplifyModelRegistration, - configuration dataStoreConfiguration: DataStoreConfiguration = .default, + configuration dataStoreConfiguration: DataStoreConfiguration = .testDefault(), storageEngineBehaviorFactory: StorageEngineBehaviorFactory? = nil, dataStorePublisher: ModelSubcriptionBehavior, operationQueue: OperationQueue = OperationQueue(), diff --git a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Configuration/DataStoreConfiguration+Helper.swift b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Configuration/DataStoreConfiguration+Helper.swift index ae530e0bb0..cf518f0882 100644 --- a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Configuration/DataStoreConfiguration+Helper.swift +++ b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Configuration/DataStoreConfiguration+Helper.swift @@ -15,6 +15,42 @@ extension DataStoreConfiguration { public static let defaultSyncMaxRecords: UInt = 10_000 public static let defaultSyncPageSize: UInt = 1_000 + #if os(watchOS) + /// Creates a custom configuration. The only required property is `conflictHandler`. + /// + /// - Parameters: + /// - errorHandler: a callback function called on unhandled errors + /// - conflictHandler: a callback called when a conflict could not be resolved by the service + /// - syncInterval: how often the sync engine will run (in seconds) + /// - syncMaxRecords: the number of records to sync per execution + /// - syncPageSize: the page size of each sync execution + /// - authModeStrategy: authorization strategy (.default | multiauth) + /// - disableSubscriptions: called before establishing subscriptions. Return true to disable subscriptions. + /// - Returns: an instance of `DataStoreConfiguration` with the passed parameters. + public static func custom( + errorHandler: @escaping DataStoreErrorHandler = { error in + Amplify.Logging.error(error: error) + }, + conflictHandler: @escaping DataStoreConflictHandler = { _, resolve in + resolve(.applyRemote) + }, + syncInterval: TimeInterval = DataStoreConfiguration.defaultSyncInterval, + syncMaxRecords: UInt = DataStoreConfiguration.defaultSyncMaxRecords, + syncPageSize: UInt = DataStoreConfiguration.defaultSyncPageSize, + syncExpressions: [DataStoreSyncExpression] = [], + authModeStrategy: AuthModeStrategyType = .default, + disableSubscriptions: @escaping () -> Bool + ) -> DataStoreConfiguration { + return DataStoreConfiguration(errorHandler: errorHandler, + conflictHandler: conflictHandler, + syncInterval: syncInterval, + syncMaxRecords: syncMaxRecords, + syncPageSize: syncPageSize, + syncExpressions: syncExpressions, + authModeStrategy: authModeStrategy, + disableSubscriptions: disableSubscriptions) + } + #else /// Creates a custom configuration. The only required property is `conflictHandler`. /// /// - Parameters: @@ -46,10 +82,32 @@ extension DataStoreConfiguration { syncExpressions: syncExpressions, authModeStrategy: authModeStrategy) } - + #endif + + #if os(watchOS) + /// Default configuration with subscriptions disabled for watchOS. DataStore uses subscriptions via websockets, + /// which work on the watchOS simulator but not on the device. Running DataStore on watchOS with subscriptions + /// enabled is only possible during special circumstances such as actively streaming audio. + /// See https://github.com/aws-amplify/amplify-swift/pull/3368 for more details. + public static var subscriptionsDisabled: DataStoreConfiguration { + .custom(disableSubscriptions: { false }) + } + #else /// The default configuration. public static var `default`: DataStoreConfiguration { .custom() } - + #endif + + #if os(watchOS) + /// Internal method for testing + static func testDefault(disableSubscriptions: @escaping () -> Bool = { false }) -> DataStoreConfiguration { + .custom(disableSubscriptions: disableSubscriptions) + } + #else + /// Internal method for testing + static func testDefault() -> DataStoreConfiguration { + .custom() + } + #endif } diff --git a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Configuration/DataStoreConfiguration.swift b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Configuration/DataStoreConfiguration.swift index f491600882..96271bd008 100644 --- a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Configuration/DataStoreConfiguration.swift +++ b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Configuration/DataStoreConfiguration.swift @@ -70,6 +70,27 @@ public struct DataStoreConfiguration { /// Authorization mode strategy public var authModeStrategyType: AuthModeStrategyType + public let disableSubscriptions: () -> Bool + + #if os(watchOS) + init(errorHandler: @escaping DataStoreErrorHandler, + conflictHandler: @escaping DataStoreConflictHandler, + syncInterval: TimeInterval, + syncMaxRecords: UInt, + syncPageSize: UInt, + syncExpressions: [DataStoreSyncExpression], + authModeStrategy: AuthModeStrategyType = .default, + disableSubscriptions: @escaping () -> Bool) { + self.errorHandler = errorHandler + self.conflictHandler = conflictHandler + self.syncInterval = syncInterval + self.syncMaxRecords = syncMaxRecords + self.syncPageSize = syncPageSize + self.syncExpressions = syncExpressions + self.authModeStrategyType = authModeStrategy + self.disableSubscriptions = disableSubscriptions + } + #else init(errorHandler: @escaping DataStoreErrorHandler, conflictHandler: @escaping DataStoreConflictHandler, syncInterval: TimeInterval, @@ -84,6 +105,7 @@ public struct DataStoreConfiguration { self.syncPageSize = syncPageSize self.syncExpressions = syncExpressions self.authModeStrategyType = authModeStrategy + self.disableSubscriptions = { false } } - + #endif } diff --git a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/RemoteSyncEngine.swift b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/RemoteSyncEngine.swift index a32648d653..b361e0ab22 100644 --- a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/RemoteSyncEngine.swift +++ b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/RemoteSyncEngine.swift @@ -86,7 +86,7 @@ class RemoteSyncEngine: RemoteSyncEngineBehavior { authModeStrategy: resolvedAuthStrategy) let reconciliationQueueFactory = reconciliationQueueFactory ?? - AWSIncomingEventReconciliationQueue.init(modelSchemas:api:storageAdapter:syncExpressions:auth:authModeStrategy:modelReconciliationQueueFactory:) + AWSIncomingEventReconciliationQueue.init(modelSchemas:api:storageAdapter:syncExpressions:auth:authModeStrategy:modelReconciliationQueueFactory:disableSubscriptions:) let initialSyncOrchestratorFactory = initialSyncOrchestratorFactory ?? AWSInitialSyncOrchestrator.init(dataStoreConfiguration:authModeStrategy:api:reconciliationQueue:storageAdapter:) @@ -289,7 +289,8 @@ class RemoteSyncEngine: RemoteSyncEngineBehavior { dataStoreConfiguration.syncExpressions, auth, authModeStrategy, - nil) + nil, + dataStoreConfiguration.disableSubscriptions) reconciliationQueueSink = reconciliationQueue? .publisher .sink( diff --git a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/SubscriptionSync/AWSIncomingEventReconciliationQueue.swift b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/SubscriptionSync/AWSIncomingEventReconciliationQueue.swift index c9994ccbdd..0f116dec8e 100644 --- a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/SubscriptionSync/AWSIncomingEventReconciliationQueue.swift +++ b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/SubscriptionSync/AWSIncomingEventReconciliationQueue.swift @@ -10,6 +10,8 @@ import AWSPluginsCore import Combine import Foundation +typealias DisableSubscriptions = () -> Bool + // Used for testing: typealias IncomingEventReconciliationQueueFactory = ([ModelSchema], @@ -18,7 +20,8 @@ typealias IncomingEventReconciliationQueueFactory = [DataStoreSyncExpression], AuthCategoryBehavior?, AuthModeStrategy, - ModelReconciliationQueueFactory? + ModelReconciliationQueueFactory?, + @escaping DisableSubscriptions ) async -> IncomingEventReconciliationQueue final class AWSIncomingEventReconciliationQueue: IncomingEventReconciliationQueue { @@ -48,7 +51,8 @@ final class AWSIncomingEventReconciliationQueue: IncomingEventReconciliationQueu syncExpressions: [DataStoreSyncExpression], auth: AuthCategoryBehavior? = nil, authModeStrategy: AuthModeStrategy, - modelReconciliationQueueFactory: ModelReconciliationQueueFactory? = nil) async { + modelReconciliationQueueFactory: ModelReconciliationQueueFactory? = nil, + disableSubscriptions: @escaping () -> Bool = { false } ) async { self.modelSchemasCount = modelSchemas.count self.modelReconciliationQueueSinks.set([:]) self.eventReconciliationQueueTopic = CurrentValueSubject(.idle) @@ -67,6 +71,19 @@ final class AWSIncomingEventReconciliationQueue: IncomingEventReconciliationQueu self.connectionStatusSerialQueue = DispatchQueue(label: "com.amazonaws.DataStore.AWSIncomingEventReconciliationQueue") + let subscriptionsDisabled = disableSubscriptions() + + #if targetEnvironment(simulator) && os(watchOS) + if !subscriptionsDisabled { + let message = """ + DataStore uses subscriptions via websockets, which work on the watchOS simulator but not on the device. + Running DataStore on watchOS with subscriptions enabled is only possible during special circumstances + such as actively streaming audio. See https://github.com/aws-amplify/amplify-swift/pull/3368 for more details. + """ + self.log.verbose(message) + } + #endif + for modelSchema in modelSchemas { let modelName = modelSchema.name let syncExpression = syncExpressions.first(where: { @@ -78,13 +95,13 @@ final class AWSIncomingEventReconciliationQueue: IncomingEventReconciliationQueu continue } let queue = await self.modelReconciliationQueueFactory(modelSchema, - storageAdapter, - api, - reconcileAndSaveQueue, - modelPredicate, - auth, - authModeStrategy, - nil) + storageAdapter, + api, + reconcileAndSaveQueue, + modelPredicate, + auth, + authModeStrategy, + subscriptionsDisabled ? OperationDisabledIncomingSubscriptionEventPublisher() : nil) reconciliationQueues.with { reconciliationQueues in reconciliationQueues[modelName] = queue @@ -190,14 +207,15 @@ extension AWSIncomingEventReconciliationQueue: DefaultLogger { // MARK: - Static factory extension AWSIncomingEventReconciliationQueue { - static let factory: IncomingEventReconciliationQueueFactory = { modelSchemas, api, storageAdapter, syncExpressions, auth, authModeStrategy, _ in + static let factory: IncomingEventReconciliationQueueFactory = { modelSchemas, api, storageAdapter, syncExpressions, auth, authModeStrategy, _, disableSubscriptions in await AWSIncomingEventReconciliationQueue(modelSchemas: modelSchemas, - api: api, - storageAdapter: storageAdapter, - syncExpressions: syncExpressions, - auth: auth, - authModeStrategy: authModeStrategy, - modelReconciliationQueueFactory: nil) + api: api, + storageAdapter: storageAdapter, + syncExpressions: syncExpressions, + auth: auth, + authModeStrategy: authModeStrategy, + modelReconciliationQueueFactory: nil, + disableSubscriptions: disableSubscriptions) } } diff --git a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/SubscriptionSync/OperationDisabledSubscriptionEventPublisher.swift b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/SubscriptionSync/OperationDisabledSubscriptionEventPublisher.swift new file mode 100644 index 0000000000..277b4685d8 --- /dev/null +++ b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/SubscriptionSync/OperationDisabledSubscriptionEventPublisher.swift @@ -0,0 +1,31 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// + +import Amplify +import AWSPluginsCore +import Combine + +final class OperationDisabledIncomingSubscriptionEventPublisher: IncomingSubscriptionEventPublisher { + + private let subscriptionEventSubject: PassthroughSubject + + var publisher: AnyPublisher { + return subscriptionEventSubject.eraseToAnyPublisher() + } + + init() { + self.subscriptionEventSubject = PassthroughSubject() + + let apiError = APIError.operationError(AppSyncErrorType.operationDisabled.rawValue, "", nil) + let dataStoreError = DataStoreError.api(apiError, nil) + subscriptionEventSubject.send(completion: .failure(dataStoreError)) + + } + + func cancel() { + } +} diff --git a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/SubscriptionSync/ReconcileAndLocalSave/AWSModelReconciliationQueue.swift b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/SubscriptionSync/ReconcileAndLocalSave/AWSModelReconciliationQueue.swift index 7f34881c49..86c7aca2c9 100644 --- a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/SubscriptionSync/ReconcileAndLocalSave/AWSModelReconciliationQueue.swift +++ b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/SubscriptionSync/ReconcileAndLocalSave/AWSModelReconciliationQueue.swift @@ -209,8 +209,8 @@ final class AWSModelReconciliationQueue: ModelReconciliationQueue { return } if case let .api(error, _) = dataStoreError, - case let APIError.operationError(_, _, underlyingError) = error, - isOperationDisabledError(underlyingError) { + case let APIError.operationError(errorMessage, _, underlyingError) = error, + isOperationDisabledError(errorMessage, underlyingError) { log.verbose("[InitializeSubscription.3] AWSModelReconciliationQueue determined isOperationDisabledError \(modelSchema.name)") modelReconciliationQueueSubject.send(.disconnected(modelName: modelSchema.name, reason: .operationDisabled)) return @@ -284,7 +284,12 @@ extension AWSModelReconciliationQueue { return false } - private func isOperationDisabledError(_ error: Error?) -> Bool { + private func isOperationDisabledError(_ errorMessage: String?, _ error: Error?) -> Bool { + if let errorMessage = errorMessage, + case .operationDisabled = AppSyncErrorType(errorMessage) { + return true + } + if let responseError = error as? GraphQLResponseError, let graphQLError = graphqlErrors(from: responseError)?.first, let errorTypeValue = errorTypeValueFrom(graphQLError: graphQLError), diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/AWSDataStorePluginAmplifyVersionableTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/AWSDataStorePluginAmplifyVersionableTests.swift index 19f710bfba..410ac16eec 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/AWSDataStorePluginAmplifyVersionableTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/AWSDataStorePluginAmplifyVersionableTests.swift @@ -13,7 +13,12 @@ import AWSDataStorePlugin class AWSDataStorePluginAmplifyVersionableTests: XCTestCase { func testVersionExists() { + #if os(watchOS) + let plugin = AWSDataStorePlugin(modelRegistration: AmplifyModels(), + configuration: .subscriptionsDisabled) + #else let plugin = AWSDataStorePlugin(modelRegistration: AmplifyModels()) + #endif XCTAssertNotNil(plugin.version) } diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/DataStoreCategoryConfigurationTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/DataStoreCategoryConfigurationTests.swift index a60dcac2d7..8aa3354572 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/DataStoreCategoryConfigurationTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/DataStoreCategoryConfigurationTests.swift @@ -16,7 +16,13 @@ class AWSDataStorePluginConfigurationTests: XCTestCase { } func testDoesNotThrowOnMissingConfig() throws { + #if os(watchOS) + let plugin = AWSDataStorePlugin(modelRegistration: TestModelRegistration(), + configuration: .subscriptionsDisabled) + #else let plugin = AWSDataStorePlugin(modelRegistration: TestModelRegistration()) + + #endif try Amplify.add(plugin: plugin) let categoryConfig = DataStoreCategoryConfiguration(plugins: ["NonExistentPlugin": true]) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/SQLiteStorageEngineAdapterJsonTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/SQLiteStorageEngineAdapterJsonTests.swift index c1543d89d4..d71082ff45 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/SQLiteStorageEngineAdapterJsonTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/SQLiteStorageEngineAdapterJsonTests.swift @@ -36,9 +36,9 @@ class SQLiteStorageEngineAdapterJsonTests: XCTestCase { try storageAdapter.setUp(modelSchemas: StorageEngine.systemModelSchemas) let syncEngine = try RemoteSyncEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default) + dataStoreConfiguration: .testDefault()) storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/CascadeDeleteOperationTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/CascadeDeleteOperationTests.swift index dd3a7dd4ea..f7eea5c6aa 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/CascadeDeleteOperationTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/CascadeDeleteOperationTests.swift @@ -29,7 +29,7 @@ class CascadeDeleteOperationTests: StorageEngineTestsBase { syncEngine = MockRemoteSyncEngine() storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEnginePublisherTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEnginePublisherTests.swift index 3fabbb069d..6f189b06bb 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEnginePublisherTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEnginePublisherTests.swift @@ -24,7 +24,7 @@ class StorageEnginePublisherTests: StorageEngineTestsBase { try storageAdapter.setUp(modelSchemas: StorageEngine.systemModelSchemas) syncEngine = MockRemoteSyncEngine() storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsDelete.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsDelete.swift index 810db0030f..14e44c62ac 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsDelete.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsDelete.swift @@ -28,7 +28,7 @@ class StorageEngineTestsDelete: StorageEngineTestsBase { syncEngine = MockRemoteSyncEngine() storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsHasMany.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsHasMany.swift index daa980866b..98234107dc 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsHasMany.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsHasMany.swift @@ -29,7 +29,7 @@ class StorageEngineTestsHasMany: StorageEngineTestsBase { syncEngine = MockRemoteSyncEngine() storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsHasOne.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsHasOne.swift index 6adf34fd54..14133c3701 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsHasOne.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsHasOne.swift @@ -28,7 +28,7 @@ class StorageEngineTestsHasOne: StorageEngineTestsBase { syncEngine = MockRemoteSyncEngine() storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsLazyPostComment4V2Tests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsLazyPostComment4V2Tests.swift index e58def1ef1..f6801b0394 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsLazyPostComment4V2Tests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsLazyPostComment4V2Tests.swift @@ -29,7 +29,7 @@ final class StorageEngineTestsLazyPostComment4V2Tests: StorageEngineTestsBase, S syncEngine = MockRemoteSyncEngine() storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsManyToMany.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsManyToMany.swift index d7e04398d4..4280e73a26 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsManyToMany.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsManyToMany.swift @@ -28,7 +28,7 @@ class StorageEngineTestsManyToMany: StorageEngineTestsBase { syncEngine = MockRemoteSyncEngine() storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsOptionalAssociation.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsOptionalAssociation.swift index e430554d8e..ef740ed914 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsOptionalAssociation.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsOptionalAssociation.swift @@ -28,7 +28,7 @@ class StorageEngineTestsOptionalAssociation: StorageEngineTestsBase { syncEngine = MockRemoteSyncEngine() storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsPostComment4V2Tests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsPostComment4V2Tests.swift index addf726da5..d1d8ffc064 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsPostComment4V2Tests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsPostComment4V2Tests.swift @@ -28,7 +28,7 @@ final class StorageEngineTestsPostComment4V2Tests: StorageEngineTestsBase, Share syncEngine = MockRemoteSyncEngine() storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsSQLiteIndex.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsSQLiteIndex.swift index dcb8fa1c88..c13a16895d 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsSQLiteIndex.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Storage/StorageEngineTestsSQLiteIndex.swift @@ -34,7 +34,7 @@ class StorageEngineTestsSQLiteIndex: StorageEngineTestsBase { try storageAdapter.setUp(modelSchemas: StorageEngine.systemModelSchemas) syncEngine = MockRemoteSyncEngine() storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Subscribe/ObserveQueryTaskRunnerTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Subscribe/ObserveQueryTaskRunnerTests.swift index a172663280..75ede3ddd9 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Subscribe/ObserveQueryTaskRunnerTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Subscribe/ObserveQueryTaskRunnerTests.swift @@ -43,7 +43,7 @@ class ObserveQueryTaskRunnerTests: XCTestCase { sortInput: nil, storageEngine: storageEngine, dataStorePublisher: dataStorePublisher, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), dispatchedModelSyncedEvent: AtomicValue(initialValue: false), dataStoreStatePublisher: dataStoreStateSubject.eraseToAnyPublisher()) let snapshots = taskRunner.sequence @@ -96,7 +96,7 @@ class ObserveQueryTaskRunnerTests: XCTestCase { sortInput: nil, storageEngine: storageEngine, dataStorePublisher: dataStorePublisher, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), dispatchedModelSyncedEvent: dispatchedModelSyncedEvent, dataStoreStatePublisher: dataStoreStateSubject.eraseToAnyPublisher()) let snapshots = taskRunner.sequence @@ -157,7 +157,7 @@ class ObserveQueryTaskRunnerTests: XCTestCase { sortInput: nil, storageEngine: storageEngine, dataStorePublisher: dataStorePublisher, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), dispatchedModelSyncedEvent: AtomicValue(initialValue: false), dataStoreStatePublisher: dataStoreStateSubject.eraseToAnyPublisher()) let post = Post(title: "model1", @@ -204,7 +204,7 @@ class ObserveQueryTaskRunnerTests: XCTestCase { sortInput: nil, storageEngine: storageEngine, dataStorePublisher: dataStorePublisher, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), dispatchedModelSyncedEvent: AtomicValue(initialValue: false), dataStoreStatePublisher: dataStoreStateSubject.eraseToAnyPublisher()) let snapshots = taskRunner.sequence @@ -260,7 +260,7 @@ class ObserveQueryTaskRunnerTests: XCTestCase { sortInput: nil, storageEngine: storageEngine, dataStorePublisher: dataStorePublisher, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), dispatchedModelSyncedEvent: AtomicValue(initialValue: false), dataStoreStatePublisher: dataStoreStateSubject.eraseToAnyPublisher()) let snapshots = taskRunner.sequence @@ -320,7 +320,7 @@ class ObserveQueryTaskRunnerTests: XCTestCase { sortInput: nil, storageEngine: storageEngine, dataStorePublisher: dataStorePublisher, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), dispatchedModelSyncedEvent: AtomicValue(initialValue: false), dataStoreStatePublisher: dataStoreStateSubject.eraseToAnyPublisher()) let snapshots = taskRunner.sequence @@ -369,7 +369,7 @@ class ObserveQueryTaskRunnerTests: XCTestCase { sortInput: nil, storageEngine: storageEngine, dataStorePublisher: dataStorePublisher, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), dispatchedModelSyncedEvent: AtomicValue(initialValue: false), dataStoreStatePublisher: dataStoreStateSubject.eraseToAnyPublisher()) let snapshots = taskRunner.sequence @@ -409,7 +409,7 @@ class ObserveQueryTaskRunnerTests: XCTestCase { sortInput: nil, storageEngine: storageEngine, dataStorePublisher: dataStorePublisher, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), dispatchedModelSyncedEvent: AtomicValue(initialValue: false), dataStoreStatePublisher: dataStoreStateSubject.eraseToAnyPublisher()) let snapshots = taskRunner.sequence @@ -455,7 +455,7 @@ class ObserveQueryTaskRunnerTests: XCTestCase { sortInput: nil, storageEngine: storageEngine, dataStorePublisher: dataStorePublisher, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), dispatchedModelSyncedEvent: AtomicValue(initialValue: false), dataStoreStatePublisher: dataStoreStateSubject.eraseToAnyPublisher()) let snapshots = taskRunner.sequence @@ -497,7 +497,7 @@ class ObserveQueryTaskRunnerTests: XCTestCase { sortInput: nil, storageEngine: storageEngine, dataStorePublisher: dataStorePublisher, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), dispatchedModelSyncedEvent: AtomicValue(initialValue: false), dataStoreStatePublisher: dataStoreStateSubject.eraseToAnyPublisher()) let post = Post(title: "model1", @@ -556,7 +556,7 @@ class ObserveQueryTaskRunnerTests: XCTestCase { sortInput: QuerySortInput.ascending(Post.keys.id).asSortDescriptors(), storageEngine: storageEngine, dataStorePublisher: dataStorePublisher, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), dispatchedModelSyncedEvent: AtomicValue(initialValue: true), dataStoreStatePublisher: dataStoreStateSubject.eraseToAnyPublisher()) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/APICategoryDependencyTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/APICategoryDependencyTests.swift index 0c560327fe..c578764c7c 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/APICategoryDependencyTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/APICategoryDependencyTests.swift @@ -63,11 +63,11 @@ extension APICategoryDependencyTests { try storageAdapter.setUp(modelSchemas: StorageEngine.systemModelSchemas) let syncEngine = try RemoteSyncEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default) + dataStoreConfiguration: .testDefault()) let validAPIPluginKey = "MockAPICategoryPlugin" let validAuthPluginKey = "MockAuthCategoryPlugin" let storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOperationSyncExpressionTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOperationSyncExpressionTests.swift index bd78525e71..d2e0d60242 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOperationSyncExpressionTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOperationSyncExpressionTests.swift @@ -37,7 +37,14 @@ class InitialSyncOperationSyncExpressionTests: XCTestCase { func initialSyncOperation(withSyncExpression syncExpression: DataStoreSyncExpression, responder: APIPluginQueryResponder) -> InitialSyncOperation { apiPlugin.responders[.queryRequestListener] = responder - let configuration = DataStoreConfiguration.custom(syncPageSize: 10, syncExpressions: [syncExpression]) + #if os(watchOS) + let configuration = DataStoreConfiguration.custom(syncPageSize: 10, + syncExpressions: [syncExpression], + disableSubscriptions: { false }) + #else + let configuration = DataStoreConfiguration.custom(syncPageSize: 10, + syncExpressions: [syncExpression]) + #endif return InitialSyncOperation( modelSchema: MockSynced.schema, api: apiPlugin, diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOperationTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOperationTests.swift index c320409284..d5fd935321 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOperationTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOperationTests.swift @@ -51,7 +51,7 @@ class InitialSyncOperationTests: XCTestCase { api: apiPlugin, reconciliationQueue: reconciliationQueue, storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy()) let syncStartedReceived = expectation(description: "Sync started received, sync operation started") @@ -110,7 +110,7 @@ class InitialSyncOperationTests: XCTestCase { api: apiPlugin, reconciliationQueue: reconciliationQueue, storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy()) let syncStartedReceived = expectation(description: "Sync started received, sync operation started") @@ -167,7 +167,7 @@ class InitialSyncOperationTests: XCTestCase { api: apiPlugin, reconciliationQueue: reconciliationQueue, storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy()) let syncCompletionReceived = expectation(description: "Sync completion received, sync operation is complete") @@ -224,7 +224,7 @@ class InitialSyncOperationTests: XCTestCase { api: apiPlugin, reconciliationQueue: reconciliationQueue, storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy()) let syncCompletionReceived = expectation(description: "Sync completion received, sync operation is complete") @@ -291,7 +291,7 @@ class InitialSyncOperationTests: XCTestCase { api: apiPlugin, reconciliationQueue: reconciliationQueue, storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy()) let syncStartedReceived = expectation(description: "Sync started received, sync operation started") @@ -352,7 +352,7 @@ class InitialSyncOperationTests: XCTestCase { api: apiPlugin, reconciliationQueue: reconciliationQueue, storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy()) let syncStartedReceived = expectation(description: "Sync started received, sync operation started") @@ -411,6 +411,25 @@ class InitialSyncOperationTests: XCTestCase { let reconciliationQueue = MockReconciliationQueue() let expectErrorHandlerCalled = expectation(description: "Expect error handler called") + + #if os(watchOS) + let configuration = DataStoreConfiguration.custom(errorHandler: { error in + guard let dataStoreError = error as? DataStoreError, + case let .api(amplifyError, mutationEventOptional) = dataStoreError else { + XCTFail("Expected API error with mutationEvent") + return + } + guard let actualAPIError = amplifyError as? APIError, + case let .operationError(_, _, underlyingError) = actualAPIError, + let authError = underlyingError as? AuthError, + case .signedOut = authError else { + XCTFail("Should be `signedOut` error but got \(amplifyError)") + return + } + expectErrorHandlerCalled.fulfill() + XCTAssertNil(mutationEventOptional) + }, disableSubscriptions: { false }) + #else let configuration = DataStoreConfiguration.custom(errorHandler: { error in guard let dataStoreError = error as? DataStoreError, case let .api(amplifyError, mutationEventOptional) = dataStoreError else { @@ -427,6 +446,7 @@ class InitialSyncOperationTests: XCTestCase { expectErrorHandlerCalled.fulfill() XCTAssertNil(mutationEventOptional) }) + #endif let operation = InitialSyncOperation( modelSchema: MockSynced.schema, api: apiPlugin, @@ -515,7 +535,7 @@ class InitialSyncOperationTests: XCTestCase { api: apiPlugin, reconciliationQueue: reconciliationQueue, storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy()) let syncStartedReceived = expectation(description: "Sync started received, sync operation started") @@ -581,7 +601,11 @@ class InitialSyncOperationTests: XCTestCase { apiPlugin.responders[.queryRequestListener] = responder let reconciliationQueue = MockReconciliationQueue() + #if os(watchOS) + let configuration = DataStoreConfiguration.custom(syncInterval: 60, disableSubscriptions: { false }) + #else let configuration = DataStoreConfiguration.custom(syncInterval: 60) + #endif let operation = InitialSyncOperation( modelSchema: MockSynced.schema, api: apiPlugin, @@ -641,7 +665,11 @@ class InitialSyncOperationTests: XCTestCase { apiPlugin.responders[.queryRequestListener] = responder let reconciliationQueue = MockReconciliationQueue() + #if os(watchOS) + let configuration = DataStoreConfiguration.custom(syncPageSize: 10, disableSubscriptions: { false }) + #else let configuration = DataStoreConfiguration.custom(syncPageSize: 10) + #endif let operation = InitialSyncOperation( modelSchema: MockSynced.schema, api: apiPlugin, diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOrchestratorTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOrchestratorTests.swift index 5dc0082601..fbe3f5b6af 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOrchestratorTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOrchestratorTests.swift @@ -44,7 +44,7 @@ class InitialSyncOrchestratorTests: XCTestCase { let reconciliationQueue = MockReconciliationQueue() let orchestrator: AWSInitialSyncOrchestrator = - AWSInitialSyncOrchestrator(dataStoreConfiguration: .default, + AWSInitialSyncOrchestrator(dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy(), api: apiPlugin, reconciliationQueue: reconciliationQueue, @@ -144,7 +144,7 @@ class InitialSyncOrchestratorTests: XCTestCase { let reconciliationQueue = MockReconciliationQueue() let orchestrator: AWSInitialSyncOrchestrator = - AWSInitialSyncOrchestrator(dataStoreConfiguration: .default, + AWSInitialSyncOrchestrator(dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy(), api: apiPlugin, reconciliationQueue: reconciliationQueue, @@ -254,7 +254,7 @@ class InitialSyncOrchestratorTests: XCTestCase { let reconciliationQueue = MockReconciliationQueue() - let orchestrator = AWSInitialSyncOrchestrator(dataStoreConfiguration: .default, + let orchestrator = AWSInitialSyncOrchestrator(dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy(), api: apiPlugin, reconciliationQueue: reconciliationQueue, @@ -322,7 +322,7 @@ class InitialSyncOrchestratorTests: XCTestCase { let reconciliationQueue = MockReconciliationQueue() let orchestrator: AWSInitialSyncOrchestrator = - AWSInitialSyncOrchestrator(dataStoreConfiguration: .default, + AWSInitialSyncOrchestrator(dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy(), api: apiPlugin, reconciliationQueue: reconciliationQueue, @@ -397,7 +397,7 @@ class InitialSyncOrchestratorTests: XCTestCase { let reconciliationQueue = MockReconciliationQueue() let orchestrator: AWSInitialSyncOrchestrator = - AWSInitialSyncOrchestrator(dataStoreConfiguration: .default, + AWSInitialSyncOrchestrator(dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy(), api: apiPlugin, reconciliationQueue: reconciliationQueue, @@ -441,7 +441,7 @@ class InitialSyncOrchestratorTests: XCTestCase { let reconciliationQueue = MockReconciliationQueue() let orchestrator = - AWSInitialSyncOrchestrator(dataStoreConfiguration: .default, + AWSInitialSyncOrchestrator(dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy(), api: apiPlugin, reconciliationQueue: reconciliationQueue, diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/ModelSyncedEventEmitterTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/ModelSyncedEventEmitterTests.swift index 38780e8ee2..f241dc20f8 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/ModelSyncedEventEmitterTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/ModelSyncedEventEmitterTests.swift @@ -20,7 +20,7 @@ class ModelSyncedEventEmitterTests: XCTestCase { var reconciliationQueue: MockAWSIncomingEventReconciliationQueue? override func setUp() { - initialSyncOrchestrator = MockAWSInitialSyncOrchestrator(dataStoreConfiguration: .default, + initialSyncOrchestrator = MockAWSInitialSyncOrchestrator(dataStoreConfiguration: .testDefault(), api: nil, reconciliationQueue: nil, storageAdapter: nil) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/SyncEventEmitterTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/SyncEventEmitterTests.swift index 9dfbbadfa5..b74eed4313 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/SyncEventEmitterTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/SyncEventEmitterTests.swift @@ -56,7 +56,7 @@ class SyncEventEmitterTests: XCTestCase { syncExpressions: [], auth: nil) - initialSyncOrchestrator = MockAWSInitialSyncOrchestrator(dataStoreConfiguration: .default, + initialSyncOrchestrator = MockAWSInitialSyncOrchestrator(dataStoreConfiguration: .testDefault(), api: nil, reconciliationQueue: nil, storageAdapter: nil) @@ -131,7 +131,7 @@ class SyncEventEmitterTests: XCTestCase { syncExpressions: [], auth: nil) - initialSyncOrchestrator = MockAWSInitialSyncOrchestrator(dataStoreConfiguration: .default, + initialSyncOrchestrator = MockAWSInitialSyncOrchestrator(dataStoreConfiguration: .testDefault(), api: nil, reconciliationQueue: nil, storageAdapter: nil) @@ -229,7 +229,7 @@ class SyncEventEmitterTests: XCTestCase { syncExpressions: [], auth: nil) - initialSyncOrchestrator = MockAWSInitialSyncOrchestrator(dataStoreConfiguration: .default, + initialSyncOrchestrator = MockAWSInitialSyncOrchestrator(dataStoreConfiguration: .testDefault(), api: nil, reconciliationQueue: nil, storageAdapter: nil) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/LocalSubscriptionTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/LocalSubscriptionTests.swift index 31abc3a127..13d8333dc5 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/LocalSubscriptionTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/LocalSubscriptionTests.swift @@ -41,7 +41,7 @@ class LocalSubscriptionTests: XCTestCase { let syncEngine = RemoteSyncEngine( storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy(), outgoingMutationQueue: outgoingMutationQueue, mutationEventIngester: mutationDatabaseAdapter, @@ -54,7 +54,7 @@ class LocalSubscriptionTests: XCTestCase { ) storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/LocalSubscriptionWithJSONModelTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/LocalSubscriptionWithJSONModelTests.swift index 38284d7204..c20ad32848 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/LocalSubscriptionWithJSONModelTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/LocalSubscriptionWithJSONModelTests.swift @@ -43,7 +43,7 @@ class LocalSubscriptionWithJSONModelTests: XCTestCase { let syncEngine = RemoteSyncEngine( storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy(), outgoingMutationQueue: outgoingMutationQueue, mutationEventIngester: mutationDatabaseAdapter, @@ -56,7 +56,7 @@ class LocalSubscriptionWithJSONModelTests: XCTestCase { ) storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/AWSMutationEventIngesterTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/AWSMutationEventIngesterTests.swift index 03e9e0a56a..40dfb6a6b6 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/AWSMutationEventIngesterTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/AWSMutationEventIngesterTests.swift @@ -37,12 +37,12 @@ class AWSMutationEventIngesterTests: XCTestCase { try storageAdapter.setUp(modelSchemas: StorageEngine.systemModelSchemas) let syncEngine = try RemoteSyncEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default) + dataStoreConfiguration: .testDefault()) let validAPIPluginKey = "MockAPICategoryPlugin" let validAuthPluginKey = "MockAuthCategoryPlugin" let storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/OutgoingMutationQueueNetworkTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/OutgoingMutationQueueNetworkTests.swift index fecedfda2b..035918e8bf 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/OutgoingMutationQueueNetworkTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/OutgoingMutationQueueNetworkTests.swift @@ -62,7 +62,7 @@ class OutgoingMutationQueueNetworkTests: SyncEngineTestBase { let mutationQueue = OutgoingMutationQueue( storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy() ) try setUpDataStore(mutationQueue: mutationQueue) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/OutgoingMutationQueueTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/OutgoingMutationQueueTests.swift index 24f0d5a131..41f3244351 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/OutgoingMutationQueueTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/OutgoingMutationQueueTests.swift @@ -25,7 +25,7 @@ class OutgoingMutationQueueTests: SyncEngineTestBase { await tryOrFail { try setUpStorageAdapter() try setUpDataStore(mutationQueue: OutgoingMutationQueue(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy())) } let post = Post(title: "Post title", @@ -190,7 +190,7 @@ class OutgoingMutationQueueTests: SyncEngineTestBase { await tryOrFail { try setUpDataStore(mutationQueue: OutgoingMutationQueue(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy())) try await startAmplify() } diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/OutgoingMutationQueueTestsWithMockStateMachine.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/OutgoingMutationQueueTestsWithMockStateMachine.swift index 34fac59b71..d8442e9b96 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/OutgoingMutationQueueTestsWithMockStateMachine.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/OutgoingMutationQueueTestsWithMockStateMachine.swift @@ -34,7 +34,7 @@ class OutgoingMutationQueueMockStateTest: XCTestCase { storageAdapter = MockSQLiteStorageEngineAdapter() mutationQueue = OutgoingMutationQueue(stateMachine, storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy()) eventSource = MockMutationEventSource() publisher = AWSMutationEventPublisher(eventSource: eventSource) @@ -51,7 +51,7 @@ class OutgoingMutationQueueMockStateTest: XCTestCase { mutationQueue = OutgoingMutationQueue(stateMachine, storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy()) waitForExpectations(timeout: 1) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/ProcessMutationErrorFromCloudOperationTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/ProcessMutationErrorFromCloudOperationTests.swift index 2fe9e2fe98..6ba1d9d3ad 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/ProcessMutationErrorFromCloudOperationTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/MutationQueue/ProcessMutationErrorFromCloudOperationTests.swift @@ -51,7 +51,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { expectCompletion.fulfill() } let expectErrorHandlerCalled = expectation(description: "Expect error handler called") - let configuration = DataStoreConfiguration.custom(errorHandler: { error in + let configuration = custom(errorHandler: { error in guard let dataStoreError = error as? DataStoreError, case let .api(amplifyError, mutationEventOptional) = dataStoreError else { XCTFail("Expected API error with mutationEvent") @@ -97,7 +97,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { expectCompletion.fulfill() } let expectErrorHandlerCalled = expectation(description: "Expect error handler called") - let configuration = DataStoreConfiguration.custom(errorHandler: { error in + let configuration = custom(errorHandler: { error in guard let dataStoreError = error as? DataStoreError, case let .api(amplifyError, mutationEventOptional) = dataStoreError else { XCTFail("Expected API error with mutationEvent") @@ -140,7 +140,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { expectCompletion.fulfill() } let expectErrorHandlerCalled = expectation(description: "Expect error handler called") - let configuration = DataStoreConfiguration.custom(errorHandler: { error in + let configuration = custom(errorHandler: { error in guard let dataStoreError = error as? DataStoreError, case let .api(amplifyError, mutationEventOptional) = dataStoreError else { XCTFail("Expected API error with mutationEvent") @@ -183,7 +183,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { expectCompletion.fulfill() } let expectErrorHandlerCalled = expectation(description: "Expect error handler called") - let configuration = DataStoreConfiguration.custom(errorHandler: { error in + let configuration = custom(errorHandler: { error in guard let dataStoreError = error as? DataStoreError, case let .api(amplifyError, mutationEventOptional) = dataStoreError else { XCTFail("Expected API error with mutationEvent") @@ -228,7 +228,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { expectCompletion.fulfill() } let expectErrorHandlerCalled = expectation(description: "Expect error handler called") - let configuration = DataStoreConfiguration.custom(errorHandler: { error in + let configuration = custom(errorHandler: { error in guard let dataStoreError = error as? DataStoreError, case let .api(amplifyError, mutationEventOptional) = dataStoreError else { XCTFail("Expected API error with mutationEvent") @@ -279,7 +279,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { self.assertSuccessfulNil(result) expectCompletion.fulfill() } - let configuration = DataStoreConfiguration.custom(errorHandler: { error in + let configuration = custom(errorHandler: { error in guard let dataStoreError = error as? DataStoreError, case let .api(amplifyError, mutationEventOptional) = dataStoreError else { XCTFail("Expected API error with mutationEvent") @@ -319,7 +319,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { self.assertSuccessfulNil(result) expectCompletion.fulfill() } - let configuration = DataStoreConfiguration.custom(errorHandler: { error in + let configuration = custom(errorHandler: { error in guard let dataStoreError = error as? DataStoreError, case let .api(amplifyError, mutationEventOptional) = dataStoreError else { XCTFail("Expected API error with mutationEvent") @@ -358,7 +358,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { self.assertSuccessfulNil(result) expectCompletion.fulfill() } - let configuration = DataStoreConfiguration.custom(errorHandler: { error in + let configuration = custom(errorHandler: { error in guard let dataStoreError = error as? DataStoreError, case let .api(amplifyError, mutationEventOptional) = dataStoreError else { XCTFail("Expected API error with mutationEvent") @@ -397,7 +397,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { self.assertSuccessfulNil(result) expectCompletion.fulfill() } - let configuration = DataStoreConfiguration.custom(errorHandler: { error in + let configuration = custom(errorHandler: { error in guard let dataStoreError = error as? DataStoreError, case let .api(amplifyError, mutationEventOptional) = dataStoreError else { XCTFail("Expected API error with mutationEvent") @@ -449,7 +449,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { XCTAssertEqual(dataStoreError.errorDescription, "Missing remote model from the response from AppSync.") expectCompletion.fulfill() } - let operation = ProcessMutationErrorFromCloudOperation(dataStoreConfiguration: .default, + let operation = ProcessMutationErrorFromCloudOperation(dataStoreConfiguration: .testDefault(), mutationEvent: mutationEvent, api: mockAPIPlugin, storageAdapter: storageAdapter, @@ -485,7 +485,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { XCTAssertEqual(dataStoreError.errorDescription, "Should never get conflict unhandled for create mutation") expectCompletion.fulfill() } - let operation = ProcessMutationErrorFromCloudOperation(dataStoreConfiguration: .default, + let operation = ProcessMutationErrorFromCloudOperation(dataStoreConfiguration: .testDefault(), mutationEvent: mutationEvent, api: mockAPIPlugin, storageAdapter: storageAdapter, @@ -515,7 +515,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { self.assertSuccessfulNil(result) expectCompletion.fulfill() } - let operation = ProcessMutationErrorFromCloudOperation(dataStoreConfiguration: .default, + let operation = ProcessMutationErrorFromCloudOperation(dataStoreConfiguration: .testDefault(), mutationEvent: mutationEvent, api: mockAPIPlugin, storageAdapter: storageAdapter, @@ -562,7 +562,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { } let expectConflicthandlerCalled = expectation(description: "Expect conflict handler called") - let configuration = DataStoreConfiguration.custom(conflictHandler: { data, resolve in + let configuration = custom(conflictHandler: { data, resolve in guard let localPost = data.local as? Post, let remotePost = data.remote as? Post else { XCTFail("Couldn't get Posts from local and remote data") @@ -640,7 +640,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { } let expectConflicthandlerCalled = expectation(description: "Expect conflict handler called") - let configuration = DataStoreConfiguration.custom(conflictHandler: { data, resolve in + let configuration = custom(conflictHandler: { data, resolve in guard let localPost = data.local as? Post, let remotePost = data.remote as? Post else { XCTFail("Couldn't get Posts from local and remote data") @@ -734,7 +734,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { expectHubEvent.fulfill() } } - let operation = ProcessMutationErrorFromCloudOperation(dataStoreConfiguration: .default, + let operation = ProcessMutationErrorFromCloudOperation(dataStoreConfiguration: .testDefault(), mutationEvent: mutationEvent, api: mockAPIPlugin, storageAdapter: storageAdapter, @@ -797,7 +797,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { expectHubEvent.fulfill() } } - let operation = ProcessMutationErrorFromCloudOperation(dataStoreConfiguration: .default, + let operation = ProcessMutationErrorFromCloudOperation(dataStoreConfiguration: .testDefault(), mutationEvent: mutationEvent, api: mockAPIPlugin, storageAdapter: storageAdapter, @@ -867,7 +867,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { } } let expectConflicthandlerCalled = expectation(description: "Expect conflict handler called") - let configuration = DataStoreConfiguration.custom(conflictHandler: { data, resolve in + let configuration = custom(conflictHandler: { data, resolve in guard let localPost = data.local as? Post, let remotePost = data.remote as? Post else { XCTFail("Couldn't get Posts from local and remote data") @@ -936,7 +936,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { } let expectConflicthandlerCalled = expectation(description: "Expect conflict handler called") - let configuration = DataStoreConfiguration.custom(conflictHandler: { data, resolve in + let configuration = custom(conflictHandler: { data, resolve in guard let localPost = data.local as? Post, let remotePost = data.remote as? Post else { XCTFail("Couldn't get Posts from local and remote data") @@ -1016,7 +1016,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { } let expectConflicthandlerCalled = expectation(description: "Expect conflict handler called") - let configuration = DataStoreConfiguration.custom(conflictHandler: { data, resolve in + let configuration = custom(conflictHandler: { data, resolve in guard let localPost = data.local as? Post, let remotePost = data.remote as? Post else { XCTFail("Couldn't get Posts from local and remote data") @@ -1096,7 +1096,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { let expectConflicthandlerCalled = expectation(description: "Expect conflict handler called") let expectErrorHandlerCalled = expectation(description: "Expect error handler called") - let configuration = DataStoreConfiguration.custom(errorHandler: { _ in + let configuration = custom(errorHandler: { _ in expectErrorHandlerCalled.fulfill() }, conflictHandler: { data, resolve in guard let localPost = data.local as? Post, @@ -1156,7 +1156,7 @@ class ProcessMutationErrorFromCloudOperationTests: XCTestCase { errorType: .operationDisabled) let operation = ProcessMutationErrorFromCloudOperation( - dataStoreConfiguration: DataStoreConfiguration.default, + dataStoreConfiguration: DataStoreConfiguration.testDefault(), mutationEvent: mutationEvent, api: mockAPIPlugin, storageAdapter: storageAdapter, @@ -1250,4 +1250,33 @@ extension ProcessMutationErrorFromCloudOperationTests { path: nil, extensions: ["errorType": .string(errorType.rawValue)]) } + + private func custom(errorHandler: DataStoreErrorHandler? = nil, + conflictHandler: (DataStoreConflictHandler)? = nil) -> DataStoreConfiguration { + if let conflictHandler = conflictHandler, let errorHandler = errorHandler { + #if os(watchOS) + return .custom(errorHandler: errorHandler, + conflictHandler: conflictHandler, + disableSubscriptions: { false }) + #else + return .custom(errorHandler: errorHandler, + conflictHandler: conflictHandler) + #endif + } else if let errorHandler = errorHandler { + #if os(watchOS) + return .custom(errorHandler: errorHandler, + disableSubscriptions: { false }) + #else + return .custom(errorHandler: errorHandler) + #endif + } else if let conflictHandler = conflictHandler { + #if os(watchOS) + return .custom(conflictHandler: conflictHandler, + disableSubscriptions: { false }) + #else + return .custom(conflictHandler: conflictHandler) + #endif + } + return .testDefault() + } } diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/RemoteSync/RemoteSyncAPIInvocationTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/RemoteSync/RemoteSyncAPIInvocationTests.swift index 0879f7d345..0192e13ed3 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/RemoteSync/RemoteSyncAPIInvocationTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/RemoteSync/RemoteSyncAPIInvocationTests.swift @@ -41,9 +41,9 @@ class RemoteSyncAPIInvocationTests: XCTestCase { try storageAdapter.setUp(modelSchemas: StorageEngine.systemModelSchemas) let syncEngine = try RemoteSyncEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default) + dataStoreConfiguration: .testDefault()) storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/RemoteSyncEngineTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/RemoteSyncEngineTests.swift index da315bde7e..fd2686b5ab 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/RemoteSyncEngineTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/RemoteSyncEngineTests.swift @@ -33,7 +33,7 @@ class RemoteSyncEngineTests: XCTestCase { do { remoteSyncEngine = try RemoteSyncEngine( storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), outgoingMutationQueue: mockOutgoingMutationQueue, initialSyncOrchestratorFactory: MockAWSInitialSyncOrchestrator.factory, reconciliationQueueFactory: MockAWSIncomingEventReconciliationQueue.factory, diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/BaseDataStoreTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/BaseDataStoreTests.swift index 6318ef6ce8..2d91bccd89 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/BaseDataStoreTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/BaseDataStoreTests.swift @@ -36,9 +36,9 @@ class BaseDataStoreTests: XCTestCase { try storageAdapter.setUp(modelSchemas: StorageEngine.systemModelSchemas) let syncEngine = try RemoteSyncEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default) + dataStoreConfiguration: .testDefault()) storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/LocalStoreIntegrationTestBase.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/LocalStoreIntegrationTestBase.swift index 645a4df4ad..217db3315e 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/LocalStoreIntegrationTestBase.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/LocalStoreIntegrationTestBase.swift @@ -21,7 +21,12 @@ class LocalStoreIntegrationTestBase: XCTestCase { continueAfterFailure = false do { + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models, + configuration: .subscriptionsDisabled)) + #else try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models)) + #endif try Amplify.configure(AmplifyConfiguration(dataStore: nil)) } catch { XCTFail(String(describing: error)) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/Mocks/MockAWSIncomingEventReconciliationQueue.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/Mocks/MockAWSIncomingEventReconciliationQueue.swift index 6be0a7ccfc..05b5750b8a 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/Mocks/MockAWSIncomingEventReconciliationQueue.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/Mocks/MockAWSIncomingEventReconciliationQueue.swift @@ -13,7 +13,7 @@ import Combine @testable import AWSDataStorePlugin class MockAWSIncomingEventReconciliationQueue: IncomingEventReconciliationQueue { - static let factory: IncomingEventReconciliationQueueFactory = { modelSchemas, api, storageAdapter, syncExpressions, auth, _, _ in + static let factory: IncomingEventReconciliationQueueFactory = { modelSchemas, api, storageAdapter, syncExpressions, auth, _, _, _ in MockAWSIncomingEventReconciliationQueue(modelSchemas: modelSchemas, api: api, storageAdapter: storageAdapter, diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/SyncEngineTestBase.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/SyncEngineTestBase.swift index 39be1f31c2..5d69207902 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/SyncEngineTestBase.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/TestSupport/SyncEngineTestBase.swift @@ -127,7 +127,7 @@ class SyncEngineTestBase: XCTestCase { resolver: RemoteSyncEngine.Resolver.resolve(currentState:action:)) syncEngine = RemoteSyncEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), authModeStrategy: AWSDefaultAuthModeStrategy(), outgoingMutationQueue: mutationQueue, mutationEventIngester: mutationDatabaseAdapter, @@ -156,7 +156,7 @@ class SyncEngineTestBase: XCTestCase { let validAuthPluginKey = "MockAuthCategoryPlugin" let storageEngine = StorageEngine(storageAdapter: storageAdapter, - dataStoreConfiguration: .default, + dataStoreConfiguration: .testDefault(), syncEngine: syncEngine, validAPIPluginKey: validAPIPluginKey, validAuthPluginKey: validAuthPluginKey) diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginAuthCognitoTests/AWSDataStoreAuthBaseTest.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginAuthCognitoTests/AWSDataStoreAuthBaseTest.swift index f1615670ec..9b47d85f1c 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginAuthCognitoTests/AWSDataStoreAuthBaseTest.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginAuthCognitoTests/AWSDataStoreAuthBaseTest.swift @@ -164,8 +164,11 @@ class AWSDataStoreAuthBaseTest: XCTestCase { do { setupCredentials(forAuthStrategy: testType) + #if os(watchOS) + let datastoreConfig = DataStoreConfiguration.custom(authModeStrategy: testType.authStrategy, disableSubscriptions: { false }) + #else let datastoreConfig = DataStoreConfiguration.custom(authModeStrategy: testType.authStrategy) - + #endif try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models, configuration: datastoreConfig)) diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginAuthIAMTests/AWSDataStoreAuthBaseTest.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginAuthIAMTests/AWSDataStoreAuthBaseTest.swift index 885e9e590c..8f89a32442 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginAuthIAMTests/AWSDataStoreAuthBaseTest.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginAuthIAMTests/AWSDataStoreAuthBaseTest.swift @@ -195,8 +195,11 @@ class AWSDataStoreAuthBaseTest: XCTestCase { do { setupCredentials(forAuthStrategy: testType) + #if os(watchOS) + let datastoreConfig = DataStoreConfiguration.custom(authModeStrategy: testType.authStrategy, disableSubscriptions: { false }) + #else let datastoreConfig = DataStoreConfiguration.custom(authModeStrategy: testType.authStrategy) - + #endif try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models, configuration: datastoreConfig)) diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/11/AWSDataStoreIntSortKeyTest.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/11/AWSDataStoreIntSortKeyTest.swift index 57244703bd..937ec840b0 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/11/AWSDataStoreIntSortKeyTest.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/11/AWSDataStoreIntSortKeyTest.swift @@ -40,10 +40,17 @@ class AWSDataStoreIntSortKeyTest: XCTestCase { try Amplify.add(plugin: AWSAPIPlugin( sessionFactory: AmplifyURLSessionFactory()) ) + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin( + modelRegistration: TestModels(), + configuration: .custom(syncMaxRecords: 100, disableSubscriptions: { false }) + )) + #else try Amplify.add(plugin: AWSDataStorePlugin( modelRegistration: TestModels(), configuration: .custom(syncMaxRecords: 100) )) + #endif Amplify.Logging.logLevel = .verbose try Amplify.configure(config) } diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/12/AWSDataStoreFloatSortKeyTest.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/12/AWSDataStoreFloatSortKeyTest.swift index 82e1e47419..2f9fe125f7 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/12/AWSDataStoreFloatSortKeyTest.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/12/AWSDataStoreFloatSortKeyTest.swift @@ -40,10 +40,17 @@ class AWSDataStoreFloatSortKeyTest: XCTestCase { try Amplify.add(plugin: AWSAPIPlugin( sessionFactory: AmplifyURLSessionFactory()) ) + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin( + modelRegistration: TestModels(), + configuration: .custom(syncMaxRecords: 100, disableSubscriptions: { false }) + )) + #else try Amplify.add(plugin: AWSDataStorePlugin( modelRegistration: TestModels(), configuration: .custom(syncMaxRecords: 100) )) + #endif Amplify.Logging.logLevel = .verbose try Amplify.configure(config) } diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/13/AWSDataStoreDateTimeSortKeyTest.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/13/AWSDataStoreDateTimeSortKeyTest.swift index 3926927e3e..3d3e3704c9 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/13/AWSDataStoreDateTimeSortKeyTest.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/13/AWSDataStoreDateTimeSortKeyTest.swift @@ -40,10 +40,17 @@ class AWSDataStoreDateTimeSortKeyTest: XCTestCase { try Amplify.add(plugin: AWSAPIPlugin( sessionFactory: AmplifyURLSessionFactory()) ) + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin( + modelRegistration: TestModels(), + configuration: .custom(syncMaxRecords: 100, disableSubscriptions: { false }) + )) + #else try Amplify.add(plugin: AWSDataStorePlugin( modelRegistration: TestModels(), configuration: .custom(syncMaxRecords: 100) )) + #endif Amplify.Logging.logLevel = .verbose try Amplify.configure(config) } diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/14/AWSDataStoreDateSortKeyTest.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/14/AWSDataStoreDateSortKeyTest.swift index ba712b65e6..61303670f0 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/14/AWSDataStoreDateSortKeyTest.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/14/AWSDataStoreDateSortKeyTest.swift @@ -40,10 +40,17 @@ class AWSDataStoreDateSortKeyTest: XCTestCase { try Amplify.add(plugin: AWSAPIPlugin( sessionFactory: AmplifyURLSessionFactory()) ) + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin( + modelRegistration: TestModels(), + configuration: .custom(syncMaxRecords: 100, disableSubscriptions: { false }) + )) + #else try Amplify.add(plugin: AWSDataStorePlugin( modelRegistration: TestModels(), configuration: .custom(syncMaxRecords: 100) )) + #endif Amplify.Logging.logLevel = .verbose try Amplify.configure(config) } diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/15/AWSDataStoreTimeSortKeyTest.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/15/AWSDataStoreTimeSortKeyTest.swift index 256578c464..54cf724cee 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/15/AWSDataStoreTimeSortKeyTest.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/15/AWSDataStoreTimeSortKeyTest.swift @@ -40,10 +40,17 @@ class AWSDataStoreTimeSortKeyTest: XCTestCase { try Amplify.add(plugin: AWSAPIPlugin( sessionFactory: AmplifyURLSessionFactory()) ) + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin( + modelRegistration: TestModels(), + configuration: .custom(syncMaxRecords: 100, disableSubscriptions: { false }) + )) + #else try Amplify.add(plugin: AWSDataStorePlugin( modelRegistration: TestModels(), configuration: .custom(syncMaxRecords: 100) )) + #endif Amplify.Logging.logLevel = .verbose try Amplify.configure(config) } diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/9/AWSDataStoreCompositeSortKeyIdentifierTest.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/9/AWSDataStoreCompositeSortKeyIdentifierTest.swift index 35d28c67bf..f107bc47bf 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/9/AWSDataStoreCompositeSortKeyIdentifierTest.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/9/AWSDataStoreCompositeSortKeyIdentifierTest.swift @@ -34,10 +34,17 @@ class AWSDataStoreCompositeSortKeyIdentifierTest: XCTestCase { try Amplify.add(plugin: AWSAPIPlugin( sessionFactory: AmplifyURLSessionFactory()) ) + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin( + modelRegistration: TestModels(), + configuration: .custom(syncMaxRecords: 100, disableSubscriptions: { false }) + )) + #else try Amplify.add(plugin: AWSDataStorePlugin( modelRegistration: TestModels(), configuration: .custom(syncMaxRecords: 100) )) + #endif Amplify.Logging.logLevel = .verbose try Amplify.configure(config) } diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/AWSDataStorePrimaryKeyBaseTest.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/AWSDataStorePrimaryKeyBaseTest.swift index 781d532348..6f22c32ed0 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/AWSDataStorePrimaryKeyBaseTest.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/AWSDataStorePrimaryKeyBaseTest.swift @@ -36,10 +36,17 @@ class AWSDataStorePrimaryKeyBaseTest: XCTestCase { func setup(withModels models: AmplifyModelRegistration) { do { loadAmplifyConfig() + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin( + modelRegistration: models, + configuration: .custom(syncMaxRecords: 100, disableSubscriptions: { false }) + )) + #else try Amplify.add(plugin: AWSDataStorePlugin( modelRegistration: models, configuration: .custom(syncMaxRecords: 100) )) + #endif try Amplify.add(plugin: AWSAPIPlugin(sessionFactory: AmplifyURLSessionFactory())) diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/AWSDataStoreSortKeyBaseTest.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/AWSDataStoreSortKeyBaseTest.swift index 66cecade28..1eeb5518ea 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/AWSDataStoreSortKeyBaseTest.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginCPKTests/PrimaryKey/AWSDataStoreSortKeyBaseTest.swift @@ -36,10 +36,17 @@ class AWSDataStoreSortKeyBaseTest: XCTestCase { ) async throws { let config = try TestConfigHelper.retrieveAmplifyConfiguration(forResource: "testconfiguration/\(configFile)") try Amplify.add(plugin: AWSAPIPlugin(sessionFactory: AmplifyURLSessionFactory())) + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin( + modelRegistration: models, + configuration: .custom(syncMaxRecords: 100, disableSubscriptions: { false }) + )) + #else try Amplify.add(plugin: AWSDataStorePlugin( modelRegistration: models, configuration: .custom(syncMaxRecords: 100) )) + #endif Amplify.Logging.logLevel = .verbose try Amplify.configure(config) diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/AWSDataStorePluginConfigurationTests.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/AWSDataStorePluginConfigurationTests.swift index 1d829087e9..1166319a9c 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/AWSDataStorePluginConfigurationTests.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/AWSDataStorePluginConfigurationTests.swift @@ -19,7 +19,11 @@ class AWSDataStorePluginConfigurationTests: XCTestCase { // Note this test requires the ability to write a new database in the Documents directcory, so it must be embedded // in a host app func testDoesNotThrowOnMissingConfig() throws { + #if os(watchOS) + let plugin = AWSDataStorePlugin(modelRegistration: TestModelRegistration(), configuration: .subscriptionsDisabled) + #else let plugin = AWSDataStorePlugin(modelRegistration: TestModelRegistration()) + #endif try Amplify.add(plugin: plugin) let amplifyConfig = AmplifyConfiguration() diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/Connection/DataStoreConnectionScenario1Tests+WatchOS.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/Connection/DataStoreConnectionScenario1Tests+WatchOS.swift new file mode 100644 index 0000000000..c2c3aeafb7 --- /dev/null +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/Connection/DataStoreConnectionScenario1Tests+WatchOS.swift @@ -0,0 +1,77 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// + +import Foundation + +extension DataStoreConnectionScenario1Tests { + + #if os(watchOS) + func testStartAndSync() async throws { + await setUp(withModels: TestModelRegistration(), + dataStoreConfiguration: .custom(syncMaxRecords: 100, disableSubscriptions: { true })) + try await startAmplifyAndWaitForSync() + } + + func testSaveReconciled() async throws { + await setUp(withModels: TestModelRegistration(), + dataStoreConfiguration: .custom(syncMaxRecords: 100, disableSubscriptions: { true })) + try await startAmplifyAndWaitForSync() + + let team = Team1(name: "name1") + let project = Project1(team: team) + let syncedTeamReceived = expectation(description: "received team from sync path") + var hubListener = Amplify.Hub.listen(to: .dataStore, + eventName: HubPayload.EventName.DataStore.syncReceived) { payload in + guard let mutationEvent = payload.data as? MutationEvent else { + XCTFail("Could not cast payload to mutation event") + return + } + + if let syncedTeam = try? mutationEvent.decodeModel() as? Team1, + syncedTeam == team { + syncedTeamReceived.fulfill() + } + } + guard try await HubListenerTestUtilities.waitForListener(with: hubListener, timeout: 5.0) else { + XCTFail("Listener not registered for hub") + return + } + + _ = try await Amplify.DataStore.save(team) + await fulfillment(of: [syncedTeamReceived], timeout: networkTimeout) + + let syncProjectReceived = expectation(description: "received project from sync path") + hubListener = Amplify.Hub.listen(to: .dataStore, + eventName: HubPayload.EventName.DataStore.syncReceived) { payload in + guard let mutationEvent = payload.data as? MutationEvent else { + XCTFail("Could not cast payload to mutation event") + return + } + + if let syncedProject = try? mutationEvent.decodeModel() as? Project1, + syncedProject == project { + syncProjectReceived.fulfill() + } + } + guard try await HubListenerTestUtilities.waitForListener(with: hubListener, timeout: 5.0) else { + XCTFail("Listener not registered for hub") + return + } + _ = try await Amplify.DataStore.save(project) + await fulfillment(of: [syncProjectReceived], timeout: networkTimeout) + + let queriedProjectOptional = try await Amplify.DataStore.query(Project1.self, byId: project.id) + guard let queriedProject = queriedProjectOptional else { + XCTFail("Failed") + return + } + XCTAssertEqual(queriedProject.id, project.id) + XCTAssertEqual(queriedProject.team, team) + } + #endif + +} diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/Connection/DataStoreConnectionScenario1Tests.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/Connection/DataStoreConnectionScenario1Tests.swift index bb4d290b87..ae26e441e7 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/Connection/DataStoreConnectionScenario1Tests.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/Connection/DataStoreConnectionScenario1Tests.swift @@ -32,13 +32,13 @@ import XCTest */ class DataStoreConnectionScenario1Tests: SyncEngineIntegrationTestBase { - + struct TestModelRegistration: AmplifyModelRegistration { func registerModels(registry: ModelRegistry.Type) { registry.register(modelType: Team1.self) registry.register(modelType: Project1.self) } - + let version: String = "1" } diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreConfigurationTests.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreConfigurationTests.swift index 752958c841..c7762a8aaa 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreConfigurationTests.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreConfigurationTests.swift @@ -23,7 +23,11 @@ class DataStoreConfigurationTests: XCTestCase { func testConfigureWithSameSchemaDoesNotDeleteDatabase() async throws { let previousVersion = "previousVersion" do { + #if os(watchOS) + let dataStorePlugin = AWSDataStorePlugin(modelRegistration: AmplifyModels(version: previousVersion), configuration: .subscriptionsDisabled) + #else let dataStorePlugin = AWSDataStorePlugin(modelRegistration: AmplifyModels(version: previousVersion)) + #endif try Amplify.add(plugin: dataStorePlugin) try Amplify.configure(AmplifyConfiguration(dataStore: nil)) } catch { @@ -37,7 +41,11 @@ class DataStoreConfigurationTests: XCTestCase { await Amplify.reset() do { + #if os(watchOS) + let dataStorePlugin = AWSDataStorePlugin(modelRegistration: AmplifyModels(version: previousVersion), configuration: .subscriptionsDisabled) + #else let dataStorePlugin = AWSDataStorePlugin(modelRegistration: AmplifyModels(version: previousVersion)) + #endif try Amplify.add(plugin: dataStorePlugin) try Amplify.configure(AmplifyConfiguration(dataStore: nil)) } catch { @@ -60,7 +68,11 @@ class DataStoreConfigurationTests: XCTestCase { let prevoisVersion = "previousVersion" do { + #if os(watchOS) + let dataStorePlugin = AWSDataStorePlugin(modelRegistration: AmplifyModels(version: prevoisVersion), configuration: .subscriptionsDisabled) + #else let dataStorePlugin = AWSDataStorePlugin(modelRegistration: AmplifyModels(version: prevoisVersion)) + #endif try Amplify.add(plugin: dataStorePlugin) try Amplify.configure(AmplifyConfiguration(dataStore: nil)) } catch { @@ -73,7 +85,11 @@ class DataStoreConfigurationTests: XCTestCase { await Amplify.reset() do { + #if os(watchOS) + let dataStorePlugin = AWSDataStorePlugin(modelRegistration: AmplifyModels(version: "1234"), configuration: .subscriptionsDisabled) + #else let dataStorePlugin = AWSDataStorePlugin(modelRegistration: AmplifyModels(version: "1234")) + #endif try Amplify.add(plugin: dataStorePlugin) try Amplify.configure(AmplifyConfiguration(dataStore: nil)) } catch { diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreEndToEndTests.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreEndToEndTests.swift index 1576d90407..a23a537dd1 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreEndToEndTests.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreEndToEndTests.swift @@ -589,10 +589,17 @@ class DataStoreEndToEndTests: SyncEngineIntegrationTestBase { let syncExpression = DataStoreSyncExpression(modelSchema: Post.schema) { Post.keys.createdAt >= startTime } + #if os(watchOS) + await setUp( + withModels: TestModelRegistration(), + dataStoreConfiguration: .custom(syncExpressions: [syncExpression], disableSubscriptions: { false }) + ) + #else await setUp( withModels: TestModelRegistration(), dataStoreConfiguration: .custom(syncExpressions: [syncExpression]) ) + #endif try await startAmplifyAndWaitForSync() let postCount = 1_000 diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift index 2ac54a0f71..7b40d7a51f 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift @@ -164,18 +164,30 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase { /// func testInitialSyncWithPredicate() async throws { let startTime = Temporal.DateTime.now() + #if os(watchOS) + let configuration: DataStoreConfiguration = .custom( + syncMaxRecords: 100, + syncExpressions: [ + DataStoreSyncExpression( + modelSchema: Post.schema, + modelPredicate: { Post.keys.createdAt.ge(startTime) } + ) + ], + disableSubscriptions: { false }) + #else + let configuration: DataStoreConfiguration = .custom( + syncMaxRecords: 100, + syncExpressions: [ + DataStoreSyncExpression( + modelSchema: Post.schema, + modelPredicate: { Post.keys.createdAt.ge(startTime) } + ) + ]) + #endif await setUp( withModels: TestModelRegistration(), logLevel: .verbose, - dataStoreConfiguration: .custom( - syncMaxRecords: 100, - syncExpressions: [ - DataStoreSyncExpression( - modelSchema: Post.schema, - modelPredicate: { Post.keys.createdAt.ge(startTime) } - ) - ] - ) + dataStoreConfiguration: configuration ) try startAmplify() diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/TestSupport/HubEventsIntegrationTestBase.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/TestSupport/HubEventsIntegrationTestBase.swift index 87f2eab238..9bb4167312 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/TestSupport/HubEventsIntegrationTestBase.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/TestSupport/HubEventsIntegrationTestBase.swift @@ -49,7 +49,11 @@ class HubEventsIntegrationTestBase: XCTestCase { func configureAmplify(withModels models: AmplifyModelRegistration) throws { let amplifyConfig = try TestConfigHelper.retrieveAmplifyConfiguration(forResource: Self.amplifyConfigurationFile) + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models, configuration: .subscriptionsDisabled)) + #else try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models)) + #endif try Amplify.add(plugin: AWSAPIPlugin( modelRegistration: models, sessionFactory: AmplifyURLSessionFactory() diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/TestSupport/SyncEngineIntegrationTestBase.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/TestSupport/SyncEngineIntegrationTestBase.swift index 41ed785503..33be2c76f0 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/TestSupport/SyncEngineIntegrationTestBase.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/TestSupport/SyncEngineIntegrationTestBase.swift @@ -59,12 +59,21 @@ class SyncEngineIntegrationTestBase: DataStoreTestBase { modelRegistration: models, sessionFactory: AmplifyURLSessionFactory() )) + #if os(watchOS) + try Amplify.add( + plugin: AWSDataStorePlugin( + modelRegistration: models, + configuration: dataStoreConfiguration ?? .custom(syncMaxRecords: 100, disableSubscriptions: { false }) + ) + ) + #else try Amplify.add( plugin: AWSDataStorePlugin( modelRegistration: models, configuration: dataStoreConfiguration ?? .custom(syncMaxRecords: 100) ) ) + #endif } catch { XCTFail(String(describing: error)) return diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginLazyLoadTests/LazyLoadBase/AWSDataStoreLazyLoadBaseTest.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginLazyLoadTests/LazyLoadBase/AWSDataStoreLazyLoadBaseTest.swift index d0d7ae72e5..8042b895a4 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginLazyLoadTests/LazyLoadBase/AWSDataStoreLazyLoadBaseTest.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginLazyLoadTests/LazyLoadBase/AWSDataStoreLazyLoadBaseTest.swift @@ -66,8 +66,13 @@ class AWSDataStoreLazyLoadBaseTest: XCTestCase { setupConfig() Amplify.Logging.logLevel = logLevel + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models, + configuration: .custom(syncMaxRecords: 100, disableSubscriptions: { false }))) + #else try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models, configuration: .custom(syncMaxRecords: 100))) + #endif try Amplify.add(plugin: AWSAPIPlugin(sessionFactory: AmplifyURLSessionFactory())) try Amplify.configure(amplifyConfig) @@ -85,7 +90,12 @@ class AWSDataStoreLazyLoadBaseTest: XCTestCase { setupConfig() Amplify.Logging.logLevel = logLevel + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models, configuration: .subscriptionsDisabled)) + #else try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models)) + #endif + try Amplify.configure(amplifyConfig) try await deleteMutationEvents() diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginMultiAuthTests/AWSDataStoreAuthBaseTest.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginMultiAuthTests/AWSDataStoreAuthBaseTest.swift index 04bfce9c8e..155915a31b 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginMultiAuthTests/AWSDataStoreAuthBaseTest.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginMultiAuthTests/AWSDataStoreAuthBaseTest.swift @@ -198,8 +198,12 @@ class AWSDataStoreAuthBaseTest: XCTestCase { do { setupCredentials(forAuthStrategy: testType) + #if os(watchOS) + let datastoreConfig = DataStoreConfiguration.custom(authModeStrategy: testType.authStrategy, disableSubscriptions: { false }) + #else let datastoreConfig = DataStoreConfiguration.custom(authModeStrategy: testType.authStrategy) - + #endif + try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models, configuration: datastoreConfig)) diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginV2Tests/TestSupport/SyncEngineIntegrationV2TestBase.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginV2Tests/TestSupport/SyncEngineIntegrationV2TestBase.swift index 13f11537ea..7ff6649ed0 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginV2Tests/TestSupport/SyncEngineIntegrationV2TestBase.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginV2Tests/TestSupport/SyncEngineIntegrationV2TestBase.swift @@ -53,8 +53,13 @@ class SyncEngineIntegrationV2TestBase: DataStoreTestBase { modelRegistration: models, sessionFactory: AmplifyURLSessionFactory() )) + #if os(watchOS) + try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models, + configuration: .custom(syncMaxRecords: 100, disableSubscriptions: { false }))) + #else try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: models, configuration: .custom(syncMaxRecords: 100))) + #endif } catch { XCTFail(String(describing: error)) return diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/DataStoreHostApp.xcodeproj/project.pbxproj b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/DataStoreHostApp.xcodeproj/project.pbxproj index 7d5b1c23f0..10dd122d5e 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/DataStoreHostApp.xcodeproj/project.pbxproj +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/DataStoreHostApp.xcodeproj/project.pbxproj @@ -265,6 +265,7 @@ 21977DBF289C171A005B49D6 /* TestConfigHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21977DBE289C1719005B49D6 /* TestConfigHelper.swift */; }; 219B518528E3A4B00080EDCC /* DataStoreConnectionOptionalAssociations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21BBFA00289BFE3400B32A39 /* DataStoreConnectionOptionalAssociations.swift */; }; 219B518628E3A7150080EDCC /* DataStoreHubEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21BBF9EE289BFE3400B32A39 /* DataStoreHubEvent.swift */; }; + 21A418212B0E78F400FF89E1 /* DataStoreConnectionScenario1Tests+WatchOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21A418202B0E78F400FF89E1 /* DataStoreConnectionScenario1Tests+WatchOS.swift */; }; 21AA64B72AC5D78B001C6D3B /* TodoCognitoMultiOwner+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210445622AB4F6C900420AF9 /* TodoCognitoMultiOwner+Schema.swift */; }; 21AA64B82AC5D791001C6D3B /* TodoCognitoMultiOwner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210445612AB4F6C900420AF9 /* TodoCognitoMultiOwner.swift */; }; 21AB5C2A297AE56D00CCA482 /* AWSDataStoreLazyLoadPostTagSnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21AB5C29297AE56D00CCA482 /* AWSDataStoreLazyLoadPostTagSnapshotTests.swift */; }; @@ -1724,6 +1725,7 @@ 219253BD28BFE84000820737 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 21977D84289C1633005B49D6 /* primarykey_schema.graphql */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = primarykey_schema.graphql; sourceTree = ""; }; 21977DBE289C1719005B49D6 /* TestConfigHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestConfigHelper.swift; sourceTree = ""; }; + 21A418202B0E78F400FF89E1 /* DataStoreConnectionScenario1Tests+WatchOS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataStoreConnectionScenario1Tests+WatchOS.swift"; sourceTree = ""; }; 21AB5C29297AE56D00CCA482 /* AWSDataStoreLazyLoadPostTagSnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AWSDataStoreLazyLoadPostTagSnapshotTests.swift; sourceTree = ""; }; 21AB5C4829819BF000CCA482 /* Nested.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Nested.swift; sourceTree = ""; }; 21AB5C4929819BF000CCA482 /* NestedTypeTestModel+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NestedTypeTestModel+Schema.swift"; sourceTree = ""; }; @@ -2879,6 +2881,7 @@ 21BBF9F6289BFE3400B32A39 /* DataStoreConnectionScenario4Tests.swift */, 21BBF9F4289BFE3400B32A39 /* DataStoreConnectionScenario5Tests.swift */, 21BBF9F8289BFE3400B32A39 /* DataStoreConnectionScenario6Tests.swift */, + 21A418202B0E78F400FF89E1 /* DataStoreConnectionScenario1Tests+WatchOS.swift */, ); path = Connection; sourceTree = ""; @@ -5302,6 +5305,7 @@ 21BBFDC7289C06E400B32A39 /* Blog6+Schema.swift in Sources */, 21BBFD34289C06E400B32A39 /* MenuType.swift in Sources */, 21BBFC0B289C037000B32A39 /* TestModelV2Registration.swift in Sources */, + 21A418212B0E78F400FF89E1 /* DataStoreConnectionScenario1Tests+WatchOS.swift in Sources */, 21BBFD7A289C06E400B32A39 /* Attendee8V2+Schema.swift in Sources */, 21BBFD8B289C06E400B32A39 /* ListStringContainer+Schema.swift in Sources */, 21BBFD94289C06E400B32A39 /* NestedTypeTestModel+Schema.swift in Sources */,