@@ -24,6 +24,17 @@ private struct Movie: Codable, Equatable {
2424
2525}
2626
27+ private let movies : [ Movie ] = [
28+ Movie ( id: 123 , title: " Pride and Prejudice " , comment: " A great book " ) ,
29+ Movie ( id: 456 , title: " Le Petit Prince " , comment: " A french book " ) ,
30+ Movie ( id: 2 , title: " Le Rouge et le Noir " , comment: " Another french book " ) ,
31+ Movie ( id: 1 , title: " Alice In Wonderland " , comment: " A weird book " ) ,
32+ Movie ( id: 1344 , title: " The Hobbit " , comment: " An awesome book " ) ,
33+ Movie ( id: 4 , title: " Harry Potter and the Half-Blood Prince " , comment: " The best book " ) ,
34+ Movie ( id: 42 , title: " The Hitchhiker's Guide to the Galaxy " ) ,
35+ Movie ( id: 1844 , title: " A Moreninha " , comment: " A Book from Joaquim Manuel de Macedo " )
36+ ]
37+
2738class UpdatesTests : XCTestCase {
2839
2940 private var client : MeiliSearch !
@@ -63,12 +74,11 @@ class UpdatesTests: XCTestCase {
6374 let documents : Data = try ! JSONEncoder ( ) . encode ( [ movie] )
6475
6576 self . client. addDocuments ( UID: self . uid, documents: documents, primaryKey: nil ) { result in
66-
6777 switch result {
6878 case . success( let update) :
69-
79+ print ( " YOUHOU " )
80+ print ( update)
7081 self . client. getUpdate ( UID: self . uid, update) { ( result: Result < Update . Result , Swift . Error > ) in
71-
7282 switch result {
7383 case . success( let update) :
7484 XCTAssertEqual ( " DocumentsAddition " , update. type. name)
@@ -78,9 +88,7 @@ class UpdatesTests: XCTestCase {
7888 XCTFail ( )
7989 }
8090 expectation. fulfill ( )
81-
8291 }
83-
8492 case . failure:
8593 XCTFail ( " Failed to update movie index " )
8694 }
@@ -103,7 +111,6 @@ class UpdatesTests: XCTestCase {
103111 }
104112
105113 self . client. getAllUpdates ( UID: self . uid) { ( result: Result < [ Update . Result ] , Swift . Error > ) in
106-
107114 switch result {
108115 case . success( let updates) :
109116 updates. forEach { ( update: Update . Result ) in
@@ -118,11 +125,51 @@ class UpdatesTests: XCTestCase {
118125 expectation. fulfill ( )
119126
120127 }
121-
122128 self . wait ( for: [ expectation] , timeout: 10.0 )
123129
124130 }
125131
132+ func testWaitForPendingUpdateSuccessDefault ( ) {
133+ let expectation = XCTestExpectation ( description: " Wait for pending update with default options " )
134+
135+ self . client. addDocuments (
136+ UID: self . uid,
137+ documents: movies,
138+ primaryKey: nil
139+ ) { result in
140+
141+ switch result {
142+ case . success( let update) :
143+ XCTAssertEqual ( Update ( updateId: 0 ) , update)
144+ self . client. waitForPendingUpdate ( UID: self . uid, update: update) { result in
145+ switch result {
146+ case . success( let update) :
147+ XCTAssertEqual ( update. status, Update . Status. processed)
148+ case . failure( let error) :
149+ XCTFail ( error. localizedDescription)
150+ }
151+ expectation. fulfill ( )
152+
153+ }
154+ case . failure( let error) :
155+ print ( error)
156+ XCTFail ( )
157+ }
158+ }
159+ self . wait ( for: [ expectation] , timeout: 5.0 )
160+ }
161+
162+ func testWaitForPendingUpdateSuccessEmptyOptions ( ) {
163+
164+ }
165+
166+ func testWaitForPendingUpdateSuccessWithOptions ( ) {
167+
168+ }
169+
170+ func testWaitForPendingUpdateFailure ( ) {
171+
172+ }
126173}
127174// swiftlint:enable force_unwrapping
128175// swiftlint:enable force_try
0 commit comments