File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ scripts:
3131
3232 test :
3333 description : Run tests in a specific package.
34- run : dart test
34+ run : flutter test
3535 exec :
3636 concurrency : 1
3737 packageFilters :
Original file line number Diff line number Diff line change @@ -79,13 +79,22 @@ class PowerSyncOpenFactory extends DefaultSqliteOpenFactory {
7979 }
8080
8181 void enableExtension () {
82- var powersyncLib = Platform .isIOS || Platform .isMacOS
83- ? DynamicLibrary .process ()
84- : DynamicLibrary .open (getLibraryForPlatform ());
82+ var powersyncLib = _getDynamicLibraryForPlatform ();
8583 sqlite.sqlite3.ensureExtensionLoaded (
8684 SqliteExtension .inLibrary (powersyncLib, 'sqlite3_powersync_init' ));
8785 }
8886
87+ /// Returns the dynamic library for the current platform.
88+ DynamicLibrary _getDynamicLibraryForPlatform () {
89+ /// When running tests, we need to load the library for all platforms.
90+ if (Platform .environment.containsKey ('FLUTTER_TEST' )) {
91+ return DynamicLibrary .open (getLibraryForPlatform ());
92+ }
93+ return (Platform .isIOS || Platform .isMacOS)
94+ ? DynamicLibrary .process ()
95+ : DynamicLibrary .open (getLibraryForPlatform ());
96+ }
97+
8998 void setupFunctions (sqlite.Database db) {
9099 db.createFunction (
91100 functionName: 'powersync_sleep' ,
Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ class TestOpenFactory extends PowerSyncOpenFactory {
3535 sqlite_open.open.overrideFor (sqlite_open.OperatingSystem .linux, () {
3636 return DynamicLibrary .open ('libsqlite3.so.0' );
3737 });
38+ sqlite_open.open.overrideFor (sqlite_open.OperatingSystem .macOS, () {
39+ return DynamicLibrary .open ('libsqlite3.dylib' );
40+ });
3841 return super .open (options);
3942 }
4043
You can’t perform that action at this time.
0 commit comments