File tree Expand file tree Collapse file tree 4 files changed +28
-9
lines changed
packages/sqlite_async/test/utils Expand file tree Collapse file tree 4 files changed +28
-9
lines changed Original file line number Diff line number Diff line change 11import 'package:sqlite_async/sqlite_async.dart' ;
2- import 'package:test_api/src/backend/invoker.dart' ;
32
43class TestDefaultSqliteOpenFactory extends DefaultSqliteOpenFactory {
54 final String sqlitePath;
@@ -9,14 +8,7 @@ class TestDefaultSqliteOpenFactory extends DefaultSqliteOpenFactory {
98}
109
1110abstract class AbstractTestUtils {
12- String dbPath () {
13- final test = Invoker .current! .liveTest;
14- var testName = test.test.name;
15- var testShortName =
16- testName.replaceAll (RegExp (r'[\s\./]' ), '_' ).toLowerCase ();
17- var dbName = "test-db/$testShortName .db" ;
18- return dbName;
19- }
11+ String dbPath ();
2012
2113 /// Generates a test open factory
2214 Future <TestDefaultSqliteOpenFactory > testFactory (
Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ class TestSqliteOpenFactory extends TestDefaultSqliteOpenFactory {
2626 sqlite_open.open.overrideFor (sqlite_open.OperatingSystem .linux, () {
2727 return DynamicLibrary .open (sqlitePath);
2828 });
29+ sqlite_open.open.overrideFor (sqlite_open.OperatingSystem .macOS, () {
30+ return DynamicLibrary .open (
31+ '/Users/simon/src/sqlite_async.dart/sqlite-autoconf-3480000/.libs/libsqlite3.dylib' );
32+ });
2933 final db = super .open (options);
3034
3135 db.createFunction (
Original file line number Diff line number Diff line change 11import 'abstract_test_utils.dart' ;
22
33class TestUtils extends AbstractTestUtils {
4+ @override
5+ String dbPath () {
6+ throw UnimplementedError ();
7+ }
8+
49 @override
510 Future <void > cleanDb ({required String path}) {
611 throw UnimplementedError ();
Original file line number Diff line number Diff line change 11import 'dart:async' ;
22import 'dart:js_interop' ;
3+ import 'dart:math' ;
34
45import 'package:sqlite_async/sqlite_async.dart' ;
56import 'package:test/test.dart' ;
@@ -9,6 +10,8 @@ import 'abstract_test_utils.dart';
910@JS ('URL.createObjectURL' )
1011external String _createObjectURL (Blob blob);
1112
13+ String ? _dbPath;
14+
1215class TestUtils extends AbstractTestUtils {
1316 late Future <void > _isInitialized;
1417 late final SqliteOptions webOptions;
@@ -33,6 +36,21 @@ class TestUtils extends AbstractTestUtils {
3336 wasmUri: sqliteWasmUri.toString (), workerUri: sqliteUri));
3437 }
3538
39+ @override
40+ String dbPath () {
41+ if (_dbPath case final path? ) {
42+ return path;
43+ }
44+
45+ final created = _dbPath = 'test-db/${Random ().nextInt (1 << 31 )}/test.db' ;
46+ addTearDown (() {
47+ // Pick a new path for the next test.
48+ _dbPath = null ;
49+ });
50+
51+ return created;
52+ }
53+
3654 @override
3755 Future <void > cleanDb ({required String path}) async {}
3856
You can’t perform that action at this time.
0 commit comments