Initial commit: CookIT recipe collection and week planner
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
7d7a0bc60b
173 files changed
+22803
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cookit/src/database/database.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:sqlite3/open.dart';
|
||||
|
||||
/// An in-memory database for tests, or one in [file] to test migrations. On
|
||||
/// Windows hosts the sqlite3 library comes from COOKIT_SQLITE_DLL if set,
|
||||
/// otherwise from the system's winsqlite3.dll.
|
||||
AppDatabase testDatabase({File? file}) {
|
||||
if (Platform.isWindows) {
|
||||
open.overrideFor(OperatingSystem.windows, () {
|
||||
final custom = Platform.environment['COOKIT_SQLITE_DLL'];
|
||||
return DynamicLibrary.open(custom ?? 'winsqlite3.dll');
|
||||
});
|
||||
}
|
||||
driftRuntimeOptions.dontWarnAboutMultipleDatabases = true;
|
||||
final executor = file == null ? NativeDatabase.memory() : NativeDatabase(file);
|
||||
// Synchronous stream teardown keeps widget tests from hanging on pending timers.
|
||||
return AppDatabase(DatabaseConnection(executor, closeStreamsSynchronously: true));
|
||||
}
|
||||
Reference in new issue
Block a user