@@ -132,7 +132,7 @@ class ReconcileAndLocalSaveOperationTests: XCTestCase {
132
132
133
133
func testReconcilingWithoutLocalModel( ) throws {
134
134
let expect = expectation ( description: " action .reconciled notified " )
135
- let expectedDisposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostMutationSync)
135
+ let expectedDisposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostMutationSync, . create )
136
136
stateMachine. pushExpectActionCriteria { action in
137
137
XCTAssertEqual ( action, ReconcileAndLocalSaveOperation . Action. reconciled ( expectedDisposition) )
138
138
expect. fulfill ( )
@@ -142,29 +142,28 @@ class ReconcileAndLocalSaveOperationTests: XCTestCase {
142
142
waitForExpectations ( timeout: 1 )
143
143
}
144
144
145
- func testExecuteApplyRemoteModelThatDoesNotExistLocally ( ) throws {
145
+ func testExecuteApplyRemoteModelCreate ( ) throws {
146
146
let expect = expectation ( description: " action .execute applyRemoteModel " )
147
- let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostMutationSync)
147
+ let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostMutationSync, . create )
148
148
storageAdapter. returnOnSave ( dataStoreResult: . success( anyPostMutationSync. model) )
149
149
stateMachine. pushExpectActionCriteria { action in
150
150
XCTAssertEqual ( action, ReconcileAndLocalSaveOperation . Action. applied ( self . anyPostMutationSync,
151
- existsLocally : false ) )
151
+ mutationType : . create ) )
152
152
expect. fulfill ( )
153
153
}
154
154
155
155
stateMachine. state = . executing( disposition)
156
156
waitForExpectations ( timeout: 1 )
157
157
}
158
158
159
- func testExecuteApplyRemoteModelThatExistsLocally ( ) throws {
159
+ func testExecuteApplyRemoteModelUpdate ( ) throws {
160
160
let expect = expectation ( description: " action .execute applyRemoteModel " )
161
- let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostMutationSync)
161
+ let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostMutationSync, . update )
162
162
163
163
storageAdapter. returnOnSave ( dataStoreResult: . success( anyPostMutationSync. model) )
164
- storageAdapter. returnOnQueryMutationSyncMetadata ( . some( anyPostMetadata) )
165
164
stateMachine. pushExpectActionCriteria { action in
166
165
XCTAssertEqual ( action, ReconcileAndLocalSaveOperation . Action. applied ( self . anyPostMutationSync,
167
- existsLocally : true ) )
166
+ mutationType : . update ) )
168
167
expect. fulfill ( )
169
168
}
170
169
stateMachine. state = . executing( disposition)
@@ -174,7 +173,7 @@ class ReconcileAndLocalSaveOperationTests: XCTestCase {
174
173
175
174
func testExecuteApplyRemoteModel_saveMutationFailed( ) throws {
176
175
let expect = expectation ( description: " action .execute error on save model " )
177
- let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostMutationSync)
176
+ let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostMutationSync, . create )
178
177
let error = DataStoreError . invalidModelName ( " invModelName " )
179
178
storageAdapter. returnOnSave ( dataStoreResult: . failure( error) )
180
179
stateMachine. pushExpectActionCriteria { action in
@@ -189,7 +188,7 @@ class ReconcileAndLocalSaveOperationTests: XCTestCase {
189
188
190
189
func testExecuteApplyRemoteModel_saveMutationOK_MetadataFailed( ) throws {
191
190
let expect = expectation ( description: " action .execute error on save mutation " )
192
- let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostMutationSync)
191
+ let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostMutationSync, . create )
193
192
let error = DataStoreError . invalidModelName ( " forceError " )
194
193
storageAdapter. returnOnSave ( dataStoreResult: . success( anyPostMutationSync. model) )
195
194
storageAdapter. shouldReturnErrorOnSaveMetadata = true
@@ -204,11 +203,11 @@ class ReconcileAndLocalSaveOperationTests: XCTestCase {
204
203
205
204
func testExecuteApplyRemoteModel_Delete( ) throws {
206
205
let expect = expectation ( description: " action .execute applyRemoteModel delete success case " )
207
- let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostDeletedMutationSync)
206
+ let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostDeletedMutationSync, . delete )
208
207
storageAdapter. returnOnSave ( dataStoreResult: . success( anyPostDeletedMutationSync. model) )
209
208
stateMachine. pushExpectActionCriteria { action in
210
209
XCTAssertEqual ( action, ReconcileAndLocalSaveOperation . Action. applied ( self . anyPostDeletedMutationSync,
211
- existsLocally : false ) )
210
+ mutationType : . delete ) )
212
211
expect. fulfill ( )
213
212
}
214
213
@@ -218,7 +217,7 @@ class ReconcileAndLocalSaveOperationTests: XCTestCase {
218
217
219
218
func testExecuteApplyRemoteModel_Delete_saveMutationFailed( ) throws {
220
219
let expect = expectation ( description: " action .execute applyRemoteModel delete mutation error " )
221
- let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostDeletedMutationSync)
220
+ let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostDeletedMutationSync, . delete )
222
221
let error = DataStoreError . invalidModelName ( " DelMutate " )
223
222
storageAdapter. shouldReturnErrorOnDeleteMutation = true
224
223
stateMachine. pushExpectActionCriteria { action in
@@ -233,7 +232,7 @@ class ReconcileAndLocalSaveOperationTests: XCTestCase {
233
232
234
233
func testExecuteApplyRemoteModel_Delete_saveMutationOK_saveMetadataFailed( ) throws {
235
234
let expect = expectation ( description: " action .execute applyRemoteModel delete metadata error " )
236
- let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostDeletedMutationSync)
235
+ let disposition = RemoteSyncReconciler . Disposition. applyRemoteModel ( anyPostDeletedMutationSync, . delete )
237
236
let error = DataStoreError . invalidModelName ( " forceError " )
238
237
storageAdapter. shouldReturnErrorOnSaveMetadata = true
239
238
storageAdapter. returnOnSave ( dataStoreResult: . failure( error) )
@@ -259,20 +258,6 @@ class ReconcileAndLocalSaveOperationTests: XCTestCase {
259
258
waitForExpectations ( timeout: 1 )
260
259
}
261
260
262
- func testExecuteErrorOnDisposition( ) throws {
263
- let expect = expectation ( description: " action .execute error " )
264
- let error = DataStoreError . invalidModelName ( " invModelName " )
265
- let disposition = RemoteSyncReconciler . Disposition. error ( error)
266
- stateMachine. pushExpectActionCriteria { action in
267
- XCTAssertEqual ( action, ReconcileAndLocalSaveOperation . Action. errored ( error) )
268
- expect. fulfill ( )
269
- }
270
-
271
- stateMachine. state = . executing( disposition)
272
-
273
- waitForExpectations ( timeout: 1 )
274
- }
275
-
276
261
func testNotifying( ) throws {
277
262
let hubExpect = expectation ( description: " Hub is notified " )
278
263
let notifyExpect = expectation ( description: " action .notified notified " )
@@ -286,7 +271,7 @@ class ReconcileAndLocalSaveOperationTests: XCTestCase {
286
271
notifyExpect. fulfill ( )
287
272
}
288
273
289
- stateMachine. state = . notifying( anyPostMutationSync, false )
274
+ stateMachine. state = . notifying( anyPostMutationSync, . create )
290
275
291
276
waitForExpectations ( timeout: 1 )
292
277
Amplify . Hub. removeListener ( hubListener)
0 commit comments