|
Hi, I need help to fix my integration tests. They pass locally but fail on our build server. Our pubspec.yaml matches https://drift.simonbinder.eu/docs/getting-started/#adding-the-dependency Our build.yaml: targets:
$default:
sources:
- lib/*
- lib/src/**
- lib/vfs/database/*
- lib/vfs/entities/*
- pubspec.*
- lib/$lib$
- $package$
- test/test_helpers.dart
builders:
drift_dev:
options:
apply_converters_on_variables: true
generate_values_in_copy_with: true
named_parameters: true
new_sql_code_generation: true
sqlite:
version: "3.35"
modules:
- fts5How we create the db: LazyDatabase _openConnection(Logger _log) {
return LazyDatabase(() async {
return NativeDatabase(await databaseFile(), logStatements: true,
setup: (db) {
db.execute('PRAGMA journal_mode = WAL');
db.execute('PRAGMA recursive_triggers = true');
db.execute('PRAGMA case_sensitive_like = true;');
_log.fine('executed PRAGMA statements');
});
});
@DriftDatabase(include: {'tables.moor'})
class SyncDatabase extends _$SyncDatabase {
//...
SyncDatabase({
MigrationListener migrationListener = const _NoopMigrationListener(),
QueryExecutor? queryExecutor,
}) : _migrationListener = migrationListener,
super(queryExecutor ?? _openConnection(_log));
// ...
} |
Replies: 2 comments 7 replies
|
The test are run on the host OS (linux/mac?) and not on a device. You need to ensure the version is installed there. And add this to your import 'package:sqlite3/open.dart';
import 'package:sqlite3/sqlite3.dart';
....
/// This is required in order to support the `RETURNING` keyword
/// which was added in 3.35.0 which is not available by default on MacOS.
///
/// Sqlite needs to be installed via brew.
Future<void> _configureSqlite3Library() async {
late File library;
late OperatingSystem os;
if (Platform.isMacOS) {
os = OperatingSystem.macOS;
library = File('/usr/local/opt/sqlite/bin/sqlite3');
} else if (Platform.isLinux) {
os = OperatingSystem.linux;
library = File('/usr/local/lib/libsqlite3.so');
} else {
throw AssertionError('Linux or MacOS is required to run database tests!');
}
if (!library.existsSync()) {
final general = "The sqlite3 lib was not found in '${library.path}' - please ";
if (Platform.isMacOS) {
throw AssertionError("$general run 'brew install sqlite'!");
} else {
throw AssertionError('$general follow https://www.osradar.com/install-the-latest-version-sqlite-ubuntu-20-04/ to install!');
}
}
open.overrideFor(os, () => DynamicLibrary.open(library.absolute.path));
if (sqlite3.version.versionNumber <= 3035000) {
final general = "The sqlite3 version in '${library.path}' is too old - please ";
if (Platform.isMacOS) {
throw AssertionError("$general run 'brew update && brew upgrade'!");
} else {
throw AssertionError('$general follow https://www.osradar.com/install-the-latest-version-sqlite-ubuntu-20-04/ to install!');
}
}
}
|
|
Side note, this docs page says:
and I think it's either misleading, incorrect, or unspecific. |
The test are run on the host OS (linux/mac?) and not on a device. You need to ensure the version is installed there.
I am manually compiling it for my Linux Github runners and use
brew install sqlite3for MacOS runners.Not sure if you can customize CodeMagic runners.
And add this to your
flutter_test_config.dart