Files
buzz/mobile/test/shared/push/push_relay_capability_provider_test.dart
Tom Brow 775e385471 feat(mobile): report unreadable account responses, push descriptors and saved communities
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
Signed-off-by: Tom Brow <tomb@block.xyz>
2026-11-18 12:52:43 -08:00

39 lines
1.2 KiB
Dart

import 'package:buzz/shared/diagnostics/diagnostic_reporter.dart';
import 'package:buzz/shared/push/dev_push_lease.dart';
import 'package:buzz/shared/push/push_relay_capability_provider.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
for (final (failure, reported) in <(Object, bool)>[
(const FormatException('malformed descriptor'), true),
(const BuzzPushNotAdvertised(), false),
(StateError('relay unreachable'), false),
]) {
test('$failure keeps capability inactive'
'${reported ? ' and is reported' : ''}', () async {
final reporter = _RecordingDiagnostics();
final descriptor = await discoverBuzzPushRelayCapability(
'https://relay.example',
fetchDescriptor: (_) async => throw failure,
diagnostics: reporter,
);
expect(descriptor, isNull);
expect(reporter.operations, [
if (reported) DiagnosticOperation.pushGatewayResponse,
]);
});
}
}
class _RecordingDiagnostics extends NoopDiagnosticReporter {
final operations = <DiagnosticOperation>[];
@override
void reportError(
Object error,
StackTrace? stackTrace, {
required DiagnosticOperation operation,
}) => operations.add(operation);
}