From 1c84ffa6c45fb5b84956ba4f871e219479c9e65b Mon Sep 17 00:00:00 2001 From: uvtqt Date: Fri, 13 Nov 2026 18:40:23 +0100 Subject: [PATCH] Test: mock prefs so the Health export churn test passes on macOS On a macOS host the exporter takes the Apple path, whose nap writer reads SharedPreferences. The test never mocked it, so every day hit MissingPluginException, reported "export incomplete", and the first pass exported 0 days instead of 2. CI runs on Linux (Health Connect path), so only local macOS runs failed. Mocking prefs keeps the host's own path under test instead of pinning one platform. Co-Authored-By: Claude Opus 5.5 --- test/health_export_finalized_churn_test.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/health_export_finalized_churn_test.dart b/test/health_export_finalized_churn_test.dart index 04f16ba2b..396e6062c 100644 --- a/test/health_export_finalized_churn_test.dart +++ b/test/health_export_finalized_churn_test.dart @@ -1,6 +1,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:path/path.dart' as p; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:sqflite_common_ffi/sqflite_ffi.dart'; import 'package:openstrap_edge/data/db.dart'; import 'package:openstrap_edge/health/health_export.dart'; @@ -24,6 +25,11 @@ void main() { } setUpAll(() async { + // The Apple nap writer reads its settings from here. Unmocked, it threw + // MissingPluginException on a macOS host (where the exporter takes the + // Apple path), every day reported "export incomplete", and the first + // pass exported 0 instead of 2. + SharedPreferences.setMockInitialValues({}); sqfliteFfiInit(); databaseFactory = databaseFactoryFfi; LocalDb.dbName = 'openstrap_health_churn_test.db';