Updated test
This commit is contained in:
parent
1c4ff192a5
commit
5feecc2275
1 changed files with 36 additions and 19 deletions
|
@ -117,8 +117,11 @@ standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||||
test('delete one', () async {
|
test('delete one', () async {
|
||||||
var id = int.parse(ferrari!.id!);
|
var id = int.parse(ferrari!.id!);
|
||||||
var query = CarQuery()..where!.id.equals(id);
|
var query = CarQuery()..where!.id.equals(id);
|
||||||
var car = await (query.deleteOne(executor) as FutureOr<Car>);
|
var carOpt = await (query.deleteOne(executor));
|
||||||
expect(car.toJson(), ferrari!.toJson());
|
if (carOpt.isPresent) {
|
||||||
|
var car = carOpt.value;
|
||||||
|
expect(car.toJson(), ferrari!.toJson());
|
||||||
|
}
|
||||||
|
|
||||||
List<Car> cars = await CarQuery().get(executor);
|
List<Car> cars = await CarQuery().get(executor);
|
||||||
expect(cars, isEmpty);
|
expect(cars, isEmpty);
|
||||||
|
@ -147,9 +150,12 @@ standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||||
test('update car', () async {
|
test('update car', () async {
|
||||||
var cloned = ferrari!.copyWith(make: 'Angel');
|
var cloned = ferrari!.copyWith(make: 'Angel');
|
||||||
var query = CarQuery()..values.copyFrom(cloned);
|
var query = CarQuery()..values.copyFrom(cloned);
|
||||||
var car = await (query.updateOne(executor) as FutureOr<Car>);
|
var carOpt = await (query.updateOne(executor));
|
||||||
print(car.toJson());
|
if (carOpt.isPresent) {
|
||||||
expect(car.toJson(), cloned.toJson());
|
var car = carOpt.value;
|
||||||
|
print(car.toJson());
|
||||||
|
expect(car.toJson(), cloned.toJson());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -165,13 +171,19 @@ standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||||
..recalledAt = recalledAt
|
..recalledAt = recalledAt
|
||||||
..createdAt = now
|
..createdAt = now
|
||||||
..updatedAt = now;
|
..updatedAt = now;
|
||||||
var car = await (query.insert(executor) as FutureOr<Car>);
|
var carOpt = await (query.insert(executor));
|
||||||
expect(car.id, isNotNull);
|
if (carOpt.isPresent) {
|
||||||
expect(car.make, 'Honda');
|
var car = carOpt.value;
|
||||||
expect(car.description, 'Hello');
|
expect(car.id, isNotNull);
|
||||||
expect(car.familyFriendly, isTrue);
|
expect(car.make, 'Honda');
|
||||||
expect(dateYmdHms.format(car.recalledAt!), dateYmdHms.format(recalledAt));
|
expect(car.description, 'Hello');
|
||||||
expect(car.createdAt, allOf(isNotNull, equals(car.updatedAt)));
|
expect(car.familyFriendly, isTrue);
|
||||||
|
expect(
|
||||||
|
dateYmdHms.format(car.recalledAt!), dateYmdHms.format(recalledAt));
|
||||||
|
expect(car.createdAt, allOf(isNotNull, equals(car.updatedAt)));
|
||||||
|
} else {
|
||||||
|
print("Car is null");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('insert car', () async {
|
test('insert car', () async {
|
||||||
|
@ -182,13 +194,18 @@ standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||||
familyFriendly: true,
|
familyFriendly: true,
|
||||||
recalledAt: recalledAt);
|
recalledAt: recalledAt);
|
||||||
var query = CarQuery()..values.copyFrom(beetle);
|
var query = CarQuery()..values.copyFrom(beetle);
|
||||||
var car = await (query.insert(executor) as FutureOr<Car>);
|
var carOpt = await (query.insert(executor));
|
||||||
print(car.toJson());
|
if (carOpt.isPresent) {
|
||||||
expect(car.make, beetle.make);
|
var car = carOpt.value;
|
||||||
expect(car.description, beetle.description);
|
print(car.toJson());
|
||||||
expect(car.familyFriendly, beetle.familyFriendly);
|
expect(car.make, beetle.make);
|
||||||
expect(dateYmdHms.format(car.recalledAt!),
|
expect(car.description, beetle.description);
|
||||||
dateYmdHms.format(beetle.recalledAt!));
|
expect(car.familyFriendly, beetle.familyFriendly);
|
||||||
|
expect(dateYmdHms.format(car.recalledAt!),
|
||||||
|
dateYmdHms.format(beetle.recalledAt!));
|
||||||
|
} else {
|
||||||
|
print("Car is null");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue