fix: resolve dart analyze failures in chaos_monkey_test.dart #458

Merged
guettlibot merged 2 commits from refs/pull/458/head into main 2026-06-06 03:29:42 +00:00
Showing only changes of commit 8a314b2e2c - Show all commits
+22 -11
View File
@@ -32,8 +32,13 @@ Future<ImapClient> _imapConnectPlain(
String username,
String password,
) async {
final client = ImapClient(defaultResponseTimeout: const Duration(seconds: 20));
await client.connectToServer(account.imapHost, account.imapPort, isSecure: false);
final client =
ImapClient(defaultResponseTimeout: const Duration(seconds: 20));
await client.connectToServer(
account.imapHost,
account.imapPort,
isSecure: false,
);
await client.login(username, password);
return client;
}
@@ -47,7 +52,11 @@ Future<SmtpClient> _smtpConnectPlain(
final domain =
atIndex != -1 ? account.email.substring(atIndex + 1) : account.smtpHost;
final client = SmtpClient(domain);
await client.connectToServer(account.smtpHost, account.smtpPort, isSecure: false);
await client.connectToServer(
account.smtpHost,
account.smtpPort,
isSecure: false,
);
await client.ehlo();
await client.authenticate(username, password);
return client;
@@ -122,15 +131,16 @@ void main() {
tearDown(() => db.close());
test('chaos monkey — random operations do not crash the repository', () async {
final seedStr = _env('CHAOS_SEED', '');
test('chaos monkey — random operations do not crash the repository',
() async {
final seedStr = _env('CHAOS_SEED');
final seed = seedStr.isEmpty
? DateTime.now().millisecondsSinceEpoch
: int.parse(seedStr);
final rounds = int.parse(_env('CHAOS_ROUNDS', '30'));
final rng = Random(seed);
print('chaos-monkey: seed=$seed rounds=$rounds');
stdout.writeln('chaos-monkey: seed=$seed rounds=$rounds');
// Seed INBOX with a few messages so early rounds have something to act on.
for (var i = 0; i < 3; i++) {
@@ -149,7 +159,7 @@ void main() {
for (var round = 0; round < rounds; round++) {
final action = rng.nextInt(8);
print('chaos-monkey: round=$round action=$action');
stdout.writeln('chaos-monkey: round=$round action=$action');
switch (action) {
case 0: // sync INBOX
@@ -190,8 +200,9 @@ void main() {
await emails.setFlag(e.id, flagged: !e.isFlagged);
case 6: // flush pending changes to server
final flushed = await emails.flushPendingChanges(account.id, userPass);
print('chaos-monkey: flushed $flushed pending changes');
final flushed =
await emails.flushPendingChanges(account.id, userPass);
stdout.writeln('chaos-monkey: flushed $flushed pending changes');
case 7: // delete random email
final inbox = await emails.observeEmails(account.id, 'INBOX').first;
@@ -203,8 +214,8 @@ void main() {
// Final flush and sync to confirm the server is in a consistent state.
final flushed = await emails.flushPendingChanges(account.id, userPass);
print('chaos-monkey: final flush flushed=$flushed');
stdout.writeln('chaos-monkey: final flush flushed=$flushed');
final result = await emails.syncEmails(account.id, 'INBOX');
print('chaos-monkey: final sync fetched=${result.fetched}');
stdout.writeln('chaos-monkey: final sync fetched=${result.fetched}');
});
}