diff --git a/CHANGELOG.md b/CHANGELOG.md index d01147dd..d46699d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/orm/angel_orm_test/lib/src/belongs_to_test.dart b/packages/orm/angel_orm_test/lib/src/belongs_to_test.dart index 00e19ba4..d40dc03a 100644 --- a/packages/orm/angel_orm_test/lib/src/belongs_to_test.dart +++ b/packages/orm/angel_orm_test/lib/src/belongs_to_test.dart @@ -130,11 +130,11 @@ belongsToTests(FutureOr Function() createExecutor, printSeparator('Delete stream test'); var query = BookQuery()..where!.name.equals(deathlyHallows!.name!); print(query.compile(Set(), preamble: 'DELETE', withFields: false)); - List? books = await query.delete(executor); + List 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 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); diff --git a/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart b/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart index fd392b33..70e600dc 100644 --- a/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart +++ b/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart @@ -24,7 +24,7 @@ customExprTests(FutureOr 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 Function() createExecutor, ..numbersId = numbersModel!.idAsInt ..createdAt = numbersModel!.createdAt ..updatedAt = numbersModel!.updatedAt; - var abc = await (abcQuery.insert(executor) as FutureOr); - 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'); + }); }); } diff --git a/packages/orm/angel_orm_test/lib/src/has_one_test.dart b/packages/orm/angel_orm_test/lib/src/has_one_test.dart index fcd9cedc..b9cc30ef 100644 --- a/packages/orm/angel_orm_test/lib/src/has_one_test.dart +++ b/packages/orm/angel_orm_test/lib/src/has_one_test.dart @@ -63,13 +63,19 @@ hasOneTests(FutureOr 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); - var leg = await (legQuery.updateOne(executor) as FutureOr); - 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 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); - var leg = await (legQuery.deleteOne(executor) as FutureOr); - 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); - expect(leg.foot, isNull); + var legOpt = await (legQuery.getOne(executor)); + expect(legOpt.isPresent, true); + legOpt.ifPresent((leg) { + expect(leg.foot, isNull); + }); }); }