Updated test cases

This commit is contained in:
thomashii@dukefirehawk.com 2021-05-06 11:46:11 +08:00
parent 64bddb1ff7
commit 35ea05bdef
3 changed files with 14 additions and 8 deletions

View file

@ -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 (45/54 tests passed)
* Migrated angel_orm_postgres to 3.0.0 (46/54 tests passed)
* Update orm-sdk-2.12.x boilerplate (in progress) <= Milestone 2

View file

@ -116,8 +116,11 @@ manyToManyTests(FutureOr<QueryExecutor> Function() createExecutor,
test('fetch users for role', () async {
for (var role in [canPub, canSub]) {
var query = RoleQuery()..where!.id.equals(role!.idAsInt!);
var r = await (query.getOne(executor) as FutureOr<Role>);
expect(r.users.toList(), [thosakwe]);
var rOpt = await query.getOne(executor);
expect(rOpt.isPresent, true);
rOpt.ifPresent((r) async {
expect(r.users.toList(), [thosakwe]);
});
}
});

View file

@ -818,13 +818,16 @@ class FooPivotQuery extends Query<FooPivot, FooPivotQueryWhere> {
}
var model = FooPivot();
if (row.length > 2) {
model = model.copyWith(
weirdJoin:
WeirdJoinQuery.parseRow(row.skip(2).take(2).toList()).value);
var modelOpt = WeirdJoinQuery.parseRow(row.skip(2).take(2).toList());
modelOpt.ifPresent((m) {
model = model.copyWith(weirdJoin: m);
});
}
if (row.length > 4) {
model = model.copyWith(
foo: FooQuery.parseRow(row.skip(4).take(1).toList()).value);
var modelOpt = FooQuery.parseRow(row.skip(4).take(1).toList());
modelOpt.ifPresent((m) {
model = model.copyWith(foo: m);
});
}
return Optional.ofNullable(model);
}