mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-20 09:32:29 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file-length / file length <= 250 lines (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Waiting to run
Tests / test (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
The phone showed "Not syncing" with no way to learn why: a release build keeps no log. attemptSync now records the outcome and files a sync.failed report to the board with the exception. A refresh error after a landed sync no longer marks it failed. Also: hypothesis in pyproject's dev extra; gatelock 0.16.0, claude-agent-sdk 0.2.184 and stale app pins bumped; scripts/deploy.sh as the CLAUDE.md deploy command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
2.0 KiB
Dart
59 lines
2.0 KiB
Dart
import 'package:crdt_sync_flutter/crdt_sync_flutter.dart'
|
|
show AppErrors, AppErrorsConfig, ErrorQueue;
|
|
import 'package:diet_guard_app/services/sync_attempt.dart';
|
|
import 'package:diet_guard_app/services/sync_health.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
const _config = AppErrorsConfig(
|
|
app: 'diet-guard',
|
|
repo: 'kuhyx/diet-guard',
|
|
package: 'diet_guard_app',
|
|
);
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
late ErrorQueue queue;
|
|
|
|
setUp(() async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
queue = await ErrorQueue.open(await SharedPreferences.getInstance());
|
|
AppErrors.instance = AppErrors.forTest(_config, queue);
|
|
});
|
|
|
|
tearDown(() => AppErrors.instance = null);
|
|
|
|
test('a sync that lands records success and reports nothing', () async {
|
|
expect(await attemptSync(() async {}), isTrue);
|
|
final status = await SyncHealth.read();
|
|
expect(status.lastSuccess, isNotNull);
|
|
expect(status.failureKind, isNull);
|
|
expect(queue.entries, isEmpty);
|
|
});
|
|
|
|
test('a failed sync records the failure and files its cause', () async {
|
|
final ok = await attemptSync(() async => throw StateError('locked'));
|
|
expect(ok, isFalse);
|
|
final status = await SyncHealth.read();
|
|
expect(status.failureKind, SyncFailureKind.failed);
|
|
final entry = queue.entries.single;
|
|
expect(entry.kind, 'sync.failed');
|
|
expect(entry.error, contains('locked'));
|
|
});
|
|
|
|
test('without installed reporting a failure is still recorded', () async {
|
|
AppErrors.instance = null;
|
|
expect(await attemptSync(() async => throw StateError('x')), isFalse);
|
|
expect((await SyncHealth.read()).failureKind, SyncFailureKind.failed);
|
|
});
|
|
|
|
test('a later success clears the failure (the banner goes away)', () async {
|
|
await attemptSync(() async => throw StateError('offline'));
|
|
await attemptSync(() async {});
|
|
final status = await SyncHealth.read();
|
|
expect(status.failureKind, isNull);
|
|
expect(status.message, isNull);
|
|
});
|
|
}
|