@@ -21,47 +21,50 @@ createTables(SqliteDatabase db) async {
21
21
});
22
22
}
23
23
24
- void main () {
25
- group ('Query Watch Tests' , () {
26
- late String path;
27
- List <String > sqlitePaths = [];
24
+ // Web and native have different requirements for `sqlitePaths`.
25
+ void generateSourceTableTests (
26
+ List <String > sqlitePaths, String Function () getPath) {
27
+ for (var sqlite in sqlitePaths) {
28
+ test ('getSourceTables - $sqlite ' , () async {
29
+ final db = SqliteDatabase .withFactory (
30
+ await testUtils.testFactory (path: getPath (), sqlitePath: sqlite));
31
+ await db.initialize ();
32
+ await createTables (db);
28
33
29
- setUp (() async {
30
- path = testUtils.dbPath ();
31
- sqlitePaths = testUtils.findSqliteLibraries ();
32
- await testUtils.cleanDb (path: path);
33
- });
34
+ var versionRow = await db.get ('SELECT sqlite_version() as version' );
35
+ print ('Testing SQLite ${versionRow ['version' ]} - $sqlite ' );
34
36
35
- for (var sqlite in sqlitePaths) {
36
- test ('getSourceTables - $sqlite ' , () async {
37
- final db = SqliteDatabase .withFactory (
38
- await testUtils.testFactory (path: path, sqlitePath: sqlite));
39
- await db.initialize ();
40
- await createTables (db);
37
+ final tables = await getSourceTables (db,
38
+ 'SELECT * FROM assets INNER JOIN customers ON assets.customer_id = customers.id' );
39
+ expect (tables, equals ({'assets' , 'customers' }));
41
40
42
- var versionRow = await db.get ('SELECT sqlite_version() as version' );
43
- print ('Testing SQLite ${versionRow ['version' ]} - $sqlite ' );
41
+ final tables2 = await getSourceTables (db,
42
+ 'SELECT count() FROM assets INNER JOIN "other_customers" AS oc ON assets.customer_id = oc.id AND assets.make = oc.name' );
43
+ expect (tables2, equals ({'assets' , 'other_customers' }));
44
44
45
- final tables = await getSourceTables (db,
46
- 'SELECT * FROM assets INNER JOIN customers ON assets.customer_id = customers.id' );
47
- expect (tables, equals ({'assets' , 'customers' }));
45
+ final tables3 = await getSourceTables (db, 'SELECT count() FROM assets' );
46
+ expect (tables3, equals ({'assets' }));
48
47
49
- final tables2 = await getSourceTables (db,
50
- 'SELECT count() FROM assets INNER JOIN "other_customers" AS oc ON assets.customer_id = oc.id AND assets.make = oc.name ' );
51
- expect (tables2 , equals ({'assets' , 'other_customers ' }));
48
+ final tables4 =
49
+ await getSourceTables (db, 'SELECT count() FROM assets_alias ' );
50
+ expect (tables4 , equals ({'assets' }));
52
51
53
- final tables3 = await getSourceTables (db, 'SELECT count() FROM assets' );
54
- expect (tables3, equals ({'assets' }));
52
+ final tables5 =
53
+ await getSourceTables (db, 'SELECT sqlite_version() as version' );
54
+ expect (tables5, equals (< String > {}));
55
+ });
56
+ }
57
+ }
55
58
56
- final tables4 =
57
- await getSourceTables (db, 'SELECT count() FROM assets_alias' );
58
- expect (tables4, equals ({'assets' }));
59
+ void main () {
60
+ // Shared tests for watch
61
+ group ('Query Watch Tests' , () {
62
+ late String path;
59
63
60
- final tables5 =
61
- await getSourceTables (db, 'SELECT sqlite_version() as version' );
62
- expect (tables5, equals (< String > {}));
63
- });
64
- }
64
+ setUp (() async {
65
+ path = testUtils.dbPath ();
66
+ await testUtils.cleanDb (path: path);
67
+ });
65
68
66
69
test ('watch' , () async {
67
70
final db = await testUtils.setupDatabase (path: path);
0 commit comments