From 6049d1aaa019623617b05164f27ae689bbed68d5 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Fri, 1 Jul 2022 22:56:25 +0200 Subject: [PATCH] Add test for #1902 --- .../analyzer/dart/database_parser_test.dart | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drift_dev/test/analyzer/dart/database_parser_test.dart b/drift_dev/test/analyzer/dart/database_parser_test.dart index 01b4708b..3ad8e81c 100644 --- a/drift_dev/test/analyzer/dart/database_parser_test.dart +++ b/drift_dev/test/analyzer/dart/database_parser_test.dart @@ -18,7 +18,10 @@ class MyDatabase extends _$MyDatabase { }); addTearDown(state.close); - final file = (await state.analyze('package:a/main.dart')).currentResult!; + final fileState = await state.analyze('package:a/main.dart'); + expect(fileState.errors.errors, isEmpty); + + final file = fileState.currentResult!; final db = (file as ParsedDartFile).declaredDatabases.single; expect(db.schemaVersion, 13); @@ -38,9 +41,35 @@ class MyDatabase extends _$MyDatabase { }); addTearDown(state.close); - final file = (await state.analyze('package:a/main.dart')).currentResult!; + final fileState = await state.analyze('package:a/main.dart'); + expect(fileState.errors.errors, isEmpty); + + final file = fileState.currentResult!; final db = (file as ParsedDartFile).declaredDatabases.single; expect(db.schemaVersion, 23); }); + + test('does not warn about missing tables parameter', () async { + final state = TestState.withContent({ + 'a|lib/main.dart': r''' +import 'package:drift/drift.dart'; + +@DriftDatabase(include: {'foo.drift'}) +class MyDatabase extends _$MyDatabase { + +} + +@DriftDatabase(include: {'foo.drift'}, tables: []) +class MyDatabase2 extends _$MyDatabase { + +} +''', + 'a|lib/foo.drift': '', + }); + addTearDown(state.close); + + final fileState = await state.analyze('package:a/main.dart'); + expect(fileState.errors.errors, isEmpty); + }); }