You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginIntegrationTests/Connection/DataStoreConnectionScenario6Tests.swift
+35-50Lines changed: 35 additions & 50 deletions
Original file line number
Diff line number
Diff line change
@@ -217,12 +217,17 @@ class DataStoreConnectionScenario6Tests: SyncEngineIntegrationTestBase {
217
217
}
218
218
}
219
219
220
+
/// Ensure that the delete with `.all` predicate works as expected.
221
+
/// There may be additional blogs/post/comments from other tests that are being deleted as part of this test
222
+
/// We ignore those and only assert that that 6 models created in this test were deleted successfully.
220
223
func testDeleteAll()throws{
221
224
setUp(withModels:TestModelRegistration())
222
225
trystartAmplifyAndWaitForReady()
223
226
varcancellables=Set<AnyCancellable>()
224
227
letremoteEventReceived=expectation(description:"received mutation event with version 1")
225
-
letcommentId=UUID().uuidString
228
+
remoteEventReceived.expectedFulfillmentCount =2
229
+
letcommentId1=UUID().uuidString
230
+
letcommentId2=UUID().uuidString
226
231
Amplify.DataStore.publisher(for:Comment6.self).sink{ completion in
227
232
switch completion {
228
233
case.finished:
@@ -231,70 +236,50 @@ class DataStoreConnectionScenario6Tests: SyncEngineIntegrationTestBase {
231
236
XCTFail("Failed \(error)")
232
237
}
233
238
} receiveValue:{ mutationEvent in
234
-
if mutationEvent.modelId == commentId && mutationEvent.version ==1{
239
+
if mutationEvent.modelId == commentId1 && mutationEvent.version ==1{
240
+
remoteEventReceived.fulfill()
241
+
}
242
+
if mutationEvent.modelId == commentId2 && mutationEvent.version ==1{
235
243
remoteEventReceived.fulfill()
236
244
}
237
245
}.store(in:&cancellables)
238
246
guardlet blog =saveBlog(name:"name"),
239
247
let post =savePost(title:"title", blog: blog),
240
-
saveComment(id:commentId, post: post, content:"content")!=nilelse{
241
-
XCTFail("Could not create blog, post, and comment")
248
+
saveComment(id:commentId1, post: post, content:"content")!=nilelse{
249
+
XCTFail("Could not create first set of blog, post, and comment")
242
250
return
243
251
}
244
-
wait(for:[remoteEventReceived], timeout:5)
245
-
246
-
varblogCount=0
247
-
letretrievedBlogCount=expectation(description:"retrieved blog count")
248
-
Amplify.DataStore.query(Blog6.self){ result in
249
-
switch result {
250
-
case.success(let blogs):
251
-
blogCount = blogs.count
252
-
retrievedBlogCount.fulfill()
253
-
case.failure(let error):
254
-
XCTFail("\(error)")
255
-
}
256
-
}
257
-
wait(for:[retrievedBlogCount], timeout:10)
258
-
varpostCount=0
259
-
letretrievedPostCount=expectation(description:"retrieved post count")
0 commit comments