mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Co-authored-by: npub1ft62tztwwm2x9xamk25smmuaj4sfckdkldksruf2x2jwqalffkrq0g7arr <4af4a5896e76d4629bbbb2a90def9d95609c59b6fb6d01f12a32a4e077e94d86@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub1ft62tztwwm2x9xamk25smmuaj4sfckdkldksruf2x2jwqalffkrq0g7arr <4af4a5896e76d4629bbbb2a90def9d95609c59b6fb6d01f12a32a4e077e94d86@sprout-oss.stage.blox.sqprod.co>
48 lines
1.3 KiB
Dart
48 lines
1.3 KiB
Dart
import 'package:buzz/main.dart' as app;
|
|
import 'package:buzz/shared/diagnostics/diagnostics.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
void main() {
|
|
test('startup continues when crash reporting initialization fails', () async {
|
|
SharedPreferences.setMockInitialValues({
|
|
diagnosticsConsentPreferenceKey: true,
|
|
});
|
|
final preferences = await SharedPreferences.getInstance();
|
|
final logs = <String>[];
|
|
final controller = DiagnosticsController(
|
|
preferences: preferences,
|
|
config: const SentryConfig(
|
|
dsn: 'https://public@example.invalid/1',
|
|
release: 'buzz@1.2.3',
|
|
dist: '42',
|
|
environment: 'production',
|
|
),
|
|
crashReporter: _FailingCrashReporter(),
|
|
);
|
|
|
|
await expectLater(
|
|
app.applyStartupDiagnosticsConsent(controller, log: logs.add),
|
|
completes,
|
|
);
|
|
|
|
expect(
|
|
logs.single,
|
|
contains(
|
|
'Diagnostics startup failed; continuing without crash reporting: '
|
|
'Bad state: init failed',
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
class _FailingCrashReporter implements CrashReporter {
|
|
@override
|
|
Future<void> initialize(SentryConfig config) async {
|
|
throw StateError('init failed');
|
|
}
|
|
|
|
@override
|
|
Future<void> close() async {}
|
|
}
|