From dbb2487c5cc0433fd49e51fd99d78659d88188a0 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Thu, 14 Feb 2019 14:23:37 -0500 Subject: [PATCH] add insertion test --- angel_orm_postgres/test/all_test.dart | 25 ++++++++++++++++++-- angel_orm_test/lib/src/cases/cases.dart | 8 +++---- angel_orm_test/lib/src/cases/standalone.dart | 14 +++++++++-- angel_orm_test/pubspec.yaml | 1 + 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/angel_orm_postgres/test/all_test.dart b/angel_orm_postgres/test/all_test.dart index dc14bd27..19ed3f60 100755 --- a/angel_orm_postgres/test/all_test.dart +++ b/angel_orm_postgres/test/all_test.dart @@ -1,6 +1,27 @@ +import 'dart:async'; + import 'package:angel_orm_postgres/angel_orm_postgres.dart'; +import 'package:angel_orm_test/angel_orm_test.dart'; +import 'package:postgres/postgres.dart'; import 'package:test/test.dart'; void main() { - -} \ No newline at end of file + PostgreSQLConnection _connect() { + return PostgreSQLConnection('localhost', 5432, 'angel_orm_test'); + } + + group('single', () { + PostgreSqlExecutor executor; + PostgreSQLConnection c = _connect(); + + setUp(() async { + var c = _connect(); + await c.open(); + executor = PostgreSqlExecutor(c); + }); + + tearDown(() => executor.close()); + + ormTests(() => executor); + }); +} diff --git a/angel_orm_test/lib/src/cases/cases.dart b/angel_orm_test/lib/src/cases/cases.dart index cd50020e..237de063 100755 --- a/angel_orm_test/lib/src/cases/cases.dart +++ b/angel_orm_test/lib/src/cases/cases.dart @@ -2,8 +2,6 @@ import 'package:angel_orm/angel_orm.dart'; import 'package:test/test.dart'; import 'standalone.dart'; -void Function() ormTests(QueryExecutor executor) { - return () { - group('standalone', standaloneTests(executor)); - }; -} \ No newline at end of file +void ormTests(QueryExecutor Function() executor) { + group('standalone', standaloneTests(executor)); +} diff --git a/angel_orm_test/lib/src/cases/standalone.dart b/angel_orm_test/lib/src/cases/standalone.dart index f81c1cbd..62b3af54 100755 --- a/angel_orm_test/lib/src/cases/standalone.dart +++ b/angel_orm_test/lib/src/cases/standalone.dart @@ -2,6 +2,16 @@ import 'package:angel_orm/angel_orm.dart'; import 'package:angel_orm_test/angel_orm_test.dart'; import 'package:test/test.dart'; -void Function() standaloneTests(QueryExecutor executor) { - return () {}; +void Function() standaloneTests(QueryExecutor Function() executorFn) { + return () { + test('insert one', () async { + var executor = executorFn(); + var query = TodoQuery(); + query.values + ..isComplete = false + ..text = 'Clean your dirty room'; + var todo = await query.insert(executor); + print(todo.toJson()); + }); + }; } diff --git a/angel_orm_test/pubspec.yaml b/angel_orm_test/pubspec.yaml index d6a9f1a8..f567e7dc 100755 --- a/angel_orm_test/pubspec.yaml +++ b/angel_orm_test/pubspec.yaml @@ -7,6 +7,7 @@ dependencies: angel_migration: ^2.0.0-alpha angel_model: ^1.0.0 angel_orm: ^2.0.0-dev + angel_serialize: ^2.0.0 test: ^1.0.0 dev_dependencies: angel_orm_generator: