@@ -168,25 +168,46 @@ void main() {
168168
169169 final checksums = [
170170 for (var prio = 0 ; prio <= 3 ; prio++ )
171- BucketChecksum (bucket: 'prio$prio ' , priority: prio, checksum: 0 )
171+ BucketChecksum (
172+ bucket: 'prio$prio ' , priority: prio, checksum: 10 + prio)
172173 ];
173174 syncService.addLine ({
174175 'checkpoint' : Checkpoint (
175- lastOpId: '0 ' ,
176+ lastOpId: '4 ' ,
176177 writeCheckpoint: null ,
177178 checksums: checksums,
178179 )
179180 });
181+ var operationId = 1 ;
182+
183+ void addRow (int priority) {
184+ syncService.addLine ({
185+ 'data' : {
186+ 'bucket' : 'prio$priority ' ,
187+ 'data' : [
188+ {
189+ 'checksum' : priority + 10 ,
190+ 'data' : {'name' : 'test' , 'email' : 'email' },
191+ 'op' : 'PUT' ,
192+ 'op_id' : '${operationId ++}' ,
193+ 'object_id' : 'prio$priority ' ,
194+ 'object_type' : 'customers'
195+ }
196+ ]
197+ }
198+ });
199+ }
180200
181201 // Receiving the checkpoint sets the state to downloading
182202 await expectLater (
183203 status, emits (isSyncStatus (downloading: true , hasSynced: false )));
184204
185205 // Emit partial sync complete for each priority but the last.
186206 for (var prio = 0 ; prio < 3 ; prio++ ) {
207+ addRow (prio);
187208 syncService.addLine ({
188209 'partial_checkpoint_complete' : {
189- 'last_op_id' : '0' ,
210+ 'last_op_id' : operationId. toString () ,
190211 'priority' : prio,
191212 }
192213 });
@@ -199,15 +220,22 @@ void main() {
199220 isTrue,
200221 )),
201222 );
223+
224+ await database.waitForFirstSync (priority: BucketPriority (prio));
225+ expect (await database.getAll ('SELECT * FROM customers' ),
226+ hasLength (prio + 1 ));
202227 }
203228
204229 // Complete the sync
230+ addRow (3 );
205231 syncService.addLine ({
206- 'checkpoint_complete' : {'last_op_id' : '0' }
232+ 'checkpoint_complete' : {'last_op_id' : operationId. toString () }
207233 });
208234
209235 await expectLater (
210236 status, emits (isSyncStatus (downloading: false , hasSynced: true )));
237+ await database.waitForFirstSync ();
238+ expect (await database.getAll ('SELECT * FROM customers' ), hasLength (4 ));
211239 });
212240
213241 test ('remembers last partial sync state' , () async {
0 commit comments