@@ -168,25 +168,46 @@ void main() {
168
168
169
169
final checksums = [
170
170
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)
172
173
];
173
174
syncService.addLine ({
174
175
'checkpoint' : Checkpoint (
175
- lastOpId: '0 ' ,
176
+ lastOpId: '4 ' ,
176
177
writeCheckpoint: null ,
177
178
checksums: checksums,
178
179
)
179
180
});
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
+ }
180
200
181
201
// Receiving the checkpoint sets the state to downloading
182
202
await expectLater (
183
203
status, emits (isSyncStatus (downloading: true , hasSynced: false )));
184
204
185
205
// Emit partial sync complete for each priority but the last.
186
206
for (var prio = 0 ; prio < 3 ; prio++ ) {
207
+ addRow (prio);
187
208
syncService.addLine ({
188
209
'partial_checkpoint_complete' : {
189
- 'last_op_id' : '0' ,
210
+ 'last_op_id' : operationId. toString () ,
190
211
'priority' : prio,
191
212
}
192
213
});
@@ -199,15 +220,22 @@ void main() {
199
220
isTrue,
200
221
)),
201
222
);
223
+
224
+ await database.waitForFirstSync (priority: BucketPriority (prio));
225
+ expect (await database.getAll ('SELECT * FROM customers' ),
226
+ hasLength (prio + 1 ));
202
227
}
203
228
204
229
// Complete the sync
230
+ addRow (3 );
205
231
syncService.addLine ({
206
- 'checkpoint_complete' : {'last_op_id' : '0' }
232
+ 'checkpoint_complete' : {'last_op_id' : operationId. toString () }
207
233
});
208
234
209
235
await expectLater (
210
236
status, emits (isSyncStatus (downloading: false , hasSynced: true )));
237
+ await database.waitForFirstSync ();
238
+ expect (await database.getAll ('SELECT * FROM customers' ), hasLength (4 ));
211
239
});
212
240
213
241
test ('remembers last partial sync state' , () async {
0 commit comments