Add test for #1902

This commit is contained in:
Simon Binder 2022-07-01 22:56:25 +02:00
parent a064bb719d
commit 6049d1aaa0
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
1 changed files with 31 additions and 2 deletions

View File

@ -18,7 +18,10 @@ class MyDatabase extends _$MyDatabase {
}); });
addTearDown(state.close); 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; final db = (file as ParsedDartFile).declaredDatabases.single;
expect(db.schemaVersion, 13); expect(db.schemaVersion, 13);
@ -38,9 +41,35 @@ class MyDatabase extends _$MyDatabase {
}); });
addTearDown(state.close); 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; final db = (file as ParsedDartFile).declaredDatabases.single;
expect(db.schemaVersion, 23); 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);
});
} }