Skip to content

Commit 68003d2

Browse files
committed
chore: add test asserts to box.remove()
closes #351
1 parent 4ec984a commit 68003d2

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

objectbox/test/box_test.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ void main() {
203203
e.toString().contains('same property value already exists'))));
204204
});
205205

206-
test('.put() replaces duplicate values on a unique replace field on insert', () {
206+
test('.put() replaces duplicate values on a unique replace field on insert',
207+
() {
207208
// insert without conflict
208209
box.putMany([
209210
TestEntity.uniqueReplace(replaceLong: 1, tString: 'original-1'),
@@ -219,7 +220,8 @@ void main() {
219220
expect(replaced.tString, equals('replacement-1'));
220221
});
221222

222-
test('.put() replaces duplicate values on a unique replace field on update', () {
223+
test('.put() replaces duplicate values on a unique replace field on update',
224+
() {
223225
// update without conflict
224226
var first = TestEntity.uniqueReplace(replaceLong: 1, tString: 'first');
225227
box.put(first);
@@ -478,7 +480,7 @@ void main() {
478480
bool contains = box.contains(id);
479481
expect(contains, equals(true));
480482
//check complementary
481-
box.remove(id);
483+
expect(box.remove(id), equals(true));
482484
contains = box.contains(id);
483485
expect(contains, equals(false));
484486
});
@@ -488,7 +490,7 @@ void main() {
488490
bool contains = box.containsMany(ids);
489491
expect(contains, equals(true));
490492
//check with one missing id
491-
box.remove(ids[1]);
493+
expect(box.remove(ids[1]), isTrue);
492494
contains = box.containsMany(ids);
493495
expect(contains, equals(false));
494496
//check complementary
@@ -500,12 +502,12 @@ void main() {
500502
test('.remove(id) works', () {
501503
final List<int> ids = box.putMany(simpleItems());
502504
//check if single id remove works
503-
expect(box.remove(ids[1]), equals(true));
505+
expect(box.remove(ids[1]), isTrue);
504506
expect(box.count(), equals(5));
505507
//check what happens if id already deleted -> throws OBJBOXEX 404
506508
bool success = box.remove(ids[1]);
507509
expect(box.count(), equals(5));
508-
expect(success, equals(false));
510+
expect(success, isFalse);
509511
});
510512

511513
test('.remove() returns false on non-existent item', () {

objectbox/test/relations_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,18 @@ void main() {
198198
rel.removeAt(1);
199199
check(rel, items: [1, 3], added: [], removed: [2]);
200200

201-
rel.remove(rel[1]);
201+
expect(rel.remove(rel[1]), isTrue);
202202
check(rel, items: [1], added: [], removed: [2, 3]);
203203

204204
rel.add(TestEntity(tInt: 4));
205205
check(rel, items: [1, 4], added: [4], removed: [2, 3]);
206206

207-
rel.remove(rel[1]);
207+
expect(rel.remove(rel[1]), isTrue);
208208
check(rel, items: [1], added: [], removed: [2, 3]);
209209

210210
rel.add(rel[0]);
211211
check(rel, items: [1, 1], added: [1], removed: [2, 3]);
212-
rel.remove(rel[0]);
212+
expect(rel.remove(rel[0]), isTrue);
213213
check(rel, items: [1], added: [], removed: [2, 3]);
214214
});
215215
});

objectbox/test/sync_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ void main() {
309309
Box<TestEntity>(env.store).put(TestEntity()); // not synced
310310
box.put(TestEntitySynced(value: 20));
311311
box.put(TestEntitySynced(value: 1));
312-
box.remove(1);
312+
expect(box.remove(1), isTrue);
313313
});
314314

315315
// wait for the data to be transferred
@@ -331,7 +331,7 @@ void main() {
331331
// Box<TestEntity>(env.store).put(TestEntity()); // not synced
332332
// box.put(TestEntitySynced(value: 20));
333333
// box.put(TestEntitySynced(value: 1));
334-
// box.remove(1);
334+
// expect(box.remove(1), isTrue);
335335
// });
336336
expect(events[1].length, 1);
337337
expect(events[1][0].entity, TestEntitySynced);

0 commit comments

Comments
 (0)