- Add `format` task (fvm dart format .) and pre-commit dart-format hook - Fix pre-commit task-check hook to use nix develop --command task - Add CI format-check step (dart format --set-exit-if-changed .) - Enable directives_ordering, curly_braces_in_flow_control_structures, discarded_futures, unnecessary_await_in_return, require_trailing_commas - Apply 330 trailing-comma fixes (dart fix --apply) across all files - Wrap intentional fire-and-forget futures with unawaited() to satisfy discarded_futures lint in account_sync_manager, email_repository_impl, and UI screens - Add test/integration/email_repository_imap_test.dart: 8 tests against real Stalwart (sync, body fetch+cache, send, search, flag/move/delete) - Remove 14 fake-IMAP unit tests migrated to Stalwart integration tests - Fix flushPendingChanges move test: create Trash folder before IMAP MOVE - Lower coverage gate 85%→80%: IMAP paths now tested by Stalwart (real), not counted in unit-test lcov - Delete LINTING.md (plan fully executed) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
70 lines
1.8 KiB
Dart
70 lines
1.8 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:sharedinbox/data/db/database.dart';
|
|
import 'package:sharedinbox/data/repositories/sync_log_repository_impl.dart';
|
|
|
|
import 'db_test_helper.dart';
|
|
|
|
void main() {
|
|
configureSqliteForTests();
|
|
|
|
late final db = openTestDatabase();
|
|
|
|
setUpAll(() async {
|
|
await db.into(db.accounts).insert(
|
|
AccountsCompanion.insert(
|
|
id: 'acc1',
|
|
displayName: 'Test',
|
|
email: 'test@example.com',
|
|
imapHost: 'imap.example.com',
|
|
imapPort: 993,
|
|
imapSsl: true,
|
|
smtpHost: 'smtp.example.com',
|
|
smtpPort: 587,
|
|
smtpSsl: true,
|
|
),
|
|
);
|
|
});
|
|
|
|
tearDownAll(() => db.close());
|
|
|
|
test('logs success entry', () async {
|
|
final repo = SyncLogRepositoryImpl(db);
|
|
final start = DateTime(2024, 1, 1, 10);
|
|
final end = DateTime(2024, 1, 1, 10, 0, 5);
|
|
|
|
await repo.log(
|
|
accountId: 'acc1',
|
|
success: true,
|
|
startedAt: start,
|
|
finishedAt: end,
|
|
);
|
|
|
|
final rows = await db.select(db.syncLogs).get();
|
|
expect(rows, hasLength(1));
|
|
expect(rows.first.result, 'ok');
|
|
expect(rows.first.errorMessage, null);
|
|
expect(rows.first.accountId, 'acc1');
|
|
});
|
|
|
|
test('logs error entry with message', () async {
|
|
final repo = SyncLogRepositoryImpl(db);
|
|
final start = DateTime(2024, 1, 1, 11);
|
|
final end = DateTime(2024, 1, 1, 11, 0, 2);
|
|
|
|
await repo.log(
|
|
accountId: 'acc1',
|
|
success: false,
|
|
errorMessage: 'Connection refused',
|
|
startedAt: start,
|
|
finishedAt: end,
|
|
);
|
|
|
|
final rows = await (db.select(db.syncLogs)
|
|
..where((r) => r.result.equals('error')))
|
|
.get();
|
|
expect(rows, hasLength(1));
|
|
expect(rows.first.result, 'error');
|
|
expect(rows.first.errorMessage, 'Connection refused');
|
|
});
|
|
}
|