English
Testing
Moodiary has Dart and Rust test suites. .github/workflows/quality.yml selects CI jobs based on the changed paths in a PR.
Dart
bash
fvm dart tool/task.dart test # affected packages
fvm dart tool/task.dart test --all # whole repository
fvm dart tool/task.dart test-mobile # mobile/ only- The default baseline is the merge-base of
HEADandorigin/develop(falling back toHEADif unavailable).--diff=<ref>overrides it. Uncommitted and untracked files are included, as are transitive dependents of changed packages. - Root
pubspec.yamlorpubspec.lockchanges select all packages, as does--all. - The runner passes the selected
test/directories to oneflutter testprocess at the repository root; hooks and the frontend compiler run once.
Writing repository and provider tests
Construct an in-memory database and enable foreign keys when testing cascades:
dart
final db = MoodiaryDatabase.forTesting(NativeDatabase.memory());
await db.customStatement('PRAGMA foreign_keys = ON');
addTearDown(db.close);
final repo = DiaryRepository(db);Above repositories, supply doubles via Riverpod overrides in ProviderContainer.test (or a widget ProviderScope):
dart
final container = ProviderContainer.test(
retry: (_, _) => null,
overrides: [diaryRepositoryProvider.overrideWithValue(fakeRepo)],
);Tests run with the repository root as cwd. Read repository files through repoRoot from package:moodiary_lint/testing.dart; write temporary data into each test's own Directory.systemTemp.createTempSync() directory and clean it up.
Rust
Each of the six native packages has its own crate; run checks in all of them:
bash
for d in packages/foundation/*/rust; do
(cd "$d" && cargo clippy --all-targets -- -D warnings && cargo test)
doneA cargo test --workspace in one crate does not cover the other crates.
What CI runs
| Job | Contents |
|---|---|
| Dart | check_generated → flutter analyze → check_layers → task.dart test --all |
| Rust | cargo clippy --all-targets -- -D warnings and cargo test across all six native packages |
Run fvm dart tool/task.dart analyze, test --all, and the Rust commands above for full local verification.
The license-manifest hook skips host-target builds. Rust hooks build for the host locally; CI disables the six in-repo Rust hooks before Dart tests. Dart tests never load these libraries; sqlite3_simple and sqlite3_vec still build their required host assets. The root pubspec dev-depends on moodiary_data (for sqlite3_simple / sqlite3_vec) and mui (for material_ui shaders and mui test assets).
Regenerate missing sources using Code generation. There is no root test/ directory, so bare flutter test at the root needs explicit package test paths; task.dart supplies them.