Skip to content

Commit

Permalink
Improve Resilience of Delete Test
Browse files Browse the repository at this point in the history
Sometimes it would fail stating the task was still there, I believe this was because it hadn't finished deleting. Hopefully it'll now wait.

Passed 50 iterations locally.
  • Loading branch information
Sherlouk committed Sep 28, 2023
1 parent aeb6f44 commit 41d7976
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions Tests/MeiliSearchIntegrationTests/TaskTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,25 @@ class TasksTests: XCTestCase {
addDocuments(client: self.client, uid: self.uid, primaryKey: nil) { result in
switch result {
case .success(let task):
self.client.deleteTasks(filter: .init(uids: [task.uid])) { _ in
self.client.getTasks { result in
switch result {
case .success(let tasks):
XCTAssertEqual(tasks.results[0].type, .taskDeletion)
XCTAssertNotEqual(tasks.results[1].uid, task.uid)
case .failure(let error):
dump(error)
XCTFail("Failed to get tasks")
}
self.client.deleteTasks(filter: .init(uids: [task.uid])) { result in
switch result {
case .success(let taskInfo):
self.client.waitForTask(task: taskInfo) { _ in
self.client.getTasks { result in
switch result {
case .success(let tasks):
XCTAssertEqual(tasks.results[0].type, .taskDeletion)
XCTAssertNotEqual(tasks.results[1].uid, task.uid)
case .failure(let error):
dump(error)
XCTFail("Failed to get tasks")
}

addDocExpectation.fulfill()
}
}
case .failure:
XCTFail("Failed to delete document")
addDocExpectation.fulfill()
}
}
Expand Down

0 comments on commit 41d7976

Please sign in to comment.