Update test cases
This commit is contained in:
parent
41569aa53f
commit
005e819fa9
4 changed files with 44 additions and 25 deletions
|
@ -37,7 +37,7 @@
|
|||
* Migrated angel_orm_generator to 4.0.0 (0/0 tests passed)
|
||||
* Migrated angel_migration_runner to 3.0.0 (0/0 tests passed)
|
||||
* Migrated angel_orm_test to 3.0.0 (0/0 tests passed)
|
||||
* Migrated angel_orm_postgres to 3.0.0 (25/54 tests passed)
|
||||
* Migrated angel_orm_postgres to 3.0.0 (27/54 tests passed)
|
||||
* Update orm-sdk-2.12.x boilerplate (in progress) <= Milestone 2
|
||||
|
||||
|
||||
|
|
|
@ -130,11 +130,11 @@ belongsToTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
printSeparator('Delete stream test');
|
||||
var query = BookQuery()..where!.name.equals(deathlyHallows!.name!);
|
||||
print(query.compile(Set(), preamble: 'DELETE', withFields: false));
|
||||
List<Book>? books = await query.delete(executor);
|
||||
List<Book> books = await query.delete(executor);
|
||||
expect(books, hasLength(1));
|
||||
|
||||
var book = books.first;
|
||||
expect(book.id, deathlyHallows!.id);
|
||||
expect(book.id, deathlyHallows?.id);
|
||||
expect(book.author, isNotNull);
|
||||
expect(book.author!.name, jkRowling!.name);
|
||||
});
|
||||
|
@ -142,9 +142,10 @@ belongsToTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
test('update book', () async {
|
||||
var cloned = deathlyHallows!.copyWith(name: "Sorcerer's Stone");
|
||||
var query = BookQuery()
|
||||
..where!.id.equals(int.parse(cloned.id!))
|
||||
..where?.id.equals(int.parse(cloned.id!))
|
||||
..values.copyFrom(cloned);
|
||||
var bookOpt = await (query.updateOne(executor));
|
||||
expect(bookOpt.isPresent, true);
|
||||
bookOpt.ifPresent((book) {
|
||||
print(book.toJson());
|
||||
expect(book.name, cloned.name);
|
||||
|
|
|
@ -24,7 +24,7 @@ customExprTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
tearDown(() => close!(executor));
|
||||
|
||||
test('fetches correct result', () async {
|
||||
expect(numbersModel!.two, 2);
|
||||
expect(numbersModel?.two, 2);
|
||||
});
|
||||
|
||||
test('in relation', () async {
|
||||
|
@ -34,9 +34,12 @@ customExprTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
..numbersId = numbersModel!.idAsInt
|
||||
..createdAt = numbersModel!.createdAt
|
||||
..updatedAt = numbersModel!.updatedAt;
|
||||
var abc = await (abcQuery.insert(executor) as FutureOr<Alphabet>);
|
||||
expect(abc.numbers, numbersModel);
|
||||
expect(abc.numbers!.two, 2);
|
||||
expect(abc.value, 'abc');
|
||||
var abcOpt = await (abcQuery.insert(executor));
|
||||
expect(abcOpt.isPresent, true);
|
||||
abcOpt.ifPresent((abc) {
|
||||
expect(abc.numbers, numbersModel);
|
||||
expect(abc.numbers?.two, 2);
|
||||
expect(abc.value, 'abc');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -63,13 +63,19 @@ hasOneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
var legQuery = LegQuery()
|
||||
..where!.id.equals(int.parse(originalLeg!.id!))
|
||||
..values.copyFrom(originalLeg!.copyWith(name: 'Right'));
|
||||
var foot = await (footQuery.insert(executor) as FutureOr<Foot>);
|
||||
var leg = await (legQuery.updateOne(executor) as FutureOr<Leg>);
|
||||
print(leg.toJson());
|
||||
expect(leg.name, 'Right');
|
||||
expect(leg.foot, isNotNull);
|
||||
expect(leg.foot!.id, foot.id);
|
||||
expect(leg.foot!.nToes, foot.nToes);
|
||||
var footOpt = await (footQuery.insert(executor));
|
||||
var legOpt = await (legQuery.updateOne(executor));
|
||||
expect(footOpt.isPresent, true);
|
||||
expect(legOpt.isPresent, true);
|
||||
legOpt.ifPresent((leg) {
|
||||
print(leg.toJson());
|
||||
expect(leg.name, 'Right');
|
||||
expect(leg.foot, isNotNull);
|
||||
footOpt.ifPresent((foot) {
|
||||
expect(leg.foot!.id, foot.id);
|
||||
expect(leg.foot!.nToes, foot.nToes);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('sets foot on delete', () async {
|
||||
|
@ -77,20 +83,29 @@ hasOneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
..values.legId = int.parse(originalLeg!.id!)
|
||||
..values.nToes = 5.64;
|
||||
var legQuery = LegQuery()..where!.id.equals(int.parse(originalLeg!.id!));
|
||||
var foot = await (footQuery.insert(executor) as FutureOr<Foot>);
|
||||
var leg = await (legQuery.deleteOne(executor) as FutureOr<Leg>);
|
||||
print(leg.toJson());
|
||||
expect(leg.name, originalLeg!.name);
|
||||
expect(leg.foot, isNotNull);
|
||||
expect(leg.foot!.id, foot.id);
|
||||
expect(leg.foot!.nToes, foot.nToes);
|
||||
var footOpt = await (footQuery.insert(executor));
|
||||
var legOpt = await (legQuery.deleteOne(executor));
|
||||
expect(footOpt.isPresent, true);
|
||||
expect(legOpt.isPresent, true);
|
||||
legOpt.ifPresent((leg) {
|
||||
print(leg.toJson());
|
||||
expect(leg.name, originalLeg?.name);
|
||||
expect(leg.foot, isNotNull);
|
||||
footOpt.ifPresent((foot) {
|
||||
expect(leg.foot!.id, foot.id);
|
||||
expect(leg.foot!.nToes, foot.nToes);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('sets null on false subquery', () async {
|
||||
var legQuery = LegQuery()
|
||||
..where!.id.equals(originalLeg!.idAsInt!)
|
||||
..foot!.where!.legId.equals(originalLeg!.idAsInt! + 1024);
|
||||
var leg = await (legQuery.getOne(executor) as FutureOr<Leg>);
|
||||
expect(leg.foot, isNull);
|
||||
var legOpt = await (legQuery.getOne(executor));
|
||||
expect(legOpt.isPresent, true);
|
||||
legOpt.ifPresent((leg) {
|
||||
expect(leg.foot, isNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue