mirror of
https://github.com/block/buzz.git
synced 2026-11-27 11:41:21 +00:00
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost> Signed-off-by: Tom Brow <tomb@block.xyz>
39 lines
1.2 KiB
Dart
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);
|
|
}
|