-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmigration_test.dart
42 lines (33 loc) · 1003 Bytes
/
migration_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@TestOn('!browser')
library;
import 'package:sqlite_async/sqlite_async.dart';
import 'package:test/test.dart';
import './utils/test_utils.dart';
import 'generated/database.dart';
void main() {
group('Migration tests', () {
late String path;
late SqliteDatabase db;
late TodoDatabase dbu;
setUp(() async {
path = dbPath();
await cleanDb(path: path);
db = await setupDatabase(path: path);
dbu = TodosMigrationDatabase(db);
});
tearDown(() async {
await dbu.close();
await db.close();
await cleanDb(path: path);
});
test('INSERT/SELECT', () async {
// This will fail if the migration didn't run
var insertRowId = await dbu
.into(dbu.todoItems)
.insert(TodoItemsCompanion.insert(description: 'Test 1'));
expect(insertRowId, greaterThanOrEqualTo(1));
final result = await dbu.select(dbu.todoItems).getSingle();
expect(result.description, equals('Test 1'));
});
});
}