Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ scripts:

test:
description: Run tests in a specific package.
run: dart test
run: flutter test
exec:
concurrency: 1
packageFilters:
Expand Down
15 changes: 12 additions & 3 deletions packages/powersync/lib/src/open_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,22 @@ class PowerSyncOpenFactory extends DefaultSqliteOpenFactory {
}

void enableExtension() {
var powersyncLib = Platform.isIOS || Platform.isMacOS
? DynamicLibrary.process()
: DynamicLibrary.open(getLibraryForPlatform());
var powersyncLib = _getDynamicLibraryForPlatform();
sqlite.sqlite3.ensureExtensionLoaded(
SqliteExtension.inLibrary(powersyncLib, 'sqlite3_powersync_init'));
}

/// Returns the dynamic library for the current platform.
DynamicLibrary _getDynamicLibraryForPlatform() {
/// When running tests, we need to load the library for all platforms.
if (Platform.environment.containsKey('FLUTTER_TEST')) {
return DynamicLibrary.open(getLibraryForPlatform());
}
return (Platform.isIOS || Platform.isMacOS)
? DynamicLibrary.process()
: DynamicLibrary.open(getLibraryForPlatform());
}

void setupFunctions(sqlite.Database db) {
db.createFunction(
functionName: 'powersync_sleep',
Expand Down
3 changes: 3 additions & 0 deletions packages/powersync/test/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class TestOpenFactory extends PowerSyncOpenFactory {
sqlite_open.open.overrideFor(sqlite_open.OperatingSystem.linux, () {
return DynamicLibrary.open('libsqlite3.so.0');
});
sqlite_open.open.overrideFor(sqlite_open.OperatingSystem.macOS, () {
return DynamicLibrary.open('libsqlite3.dylib');
});
return super.open(options);
}

Expand Down