Skip to content

Commit 72c2844

Browse files
committed
fix test
1 parent e10f9b7 commit 72c2844

File tree

2 files changed

+79
-62
lines changed

2 files changed

+79
-62
lines changed

dart/test/load_dart_debug_images_integration_test.dart

+75-62
Original file line numberDiff line numberDiff line change
@@ -5,76 +5,89 @@ import 'package:sentry/sentry.dart';
55
import 'package:sentry/src/load_dart_debug_images_integration.dart';
66
import 'package:test/test.dart';
77

8+
import 'mocks/mock_platform.dart';
9+
import 'mocks/mock_platform_checker.dart';
10+
811
void main() {
912
group(LoadDartDebugImagesIntegration(), () {
1013
late Fixture fixture;
1114

12-
setUp(() {
13-
fixture = Fixture();
14-
});
15-
16-
test('adds itself to sdk.integrations', () {
17-
expect(
18-
fixture.options.sdk.integrations.contains('loadDartImageIntegration'),
19-
true,
20-
);
21-
});
22-
23-
test('Event processor is added to options', () {
24-
expect(fixture.options.eventProcessors.length, 1);
25-
expect(
26-
fixture.options.eventProcessors.first.runtimeType.toString(),
27-
'_LoadImageIntegrationEventProcessor',
28-
);
29-
});
30-
31-
test(
32-
'Event processor does not add debug image if symbolication is not needed',
33-
() async {
34-
final event = _getEvent(needsSymbolication: false);
35-
final processor = fixture.options.eventProcessors.first;
36-
final resultEvent = await processor.apply(event, Hint());
37-
38-
expect(resultEvent, equals(event));
39-
});
40-
41-
test('Event processor does not add debug image if stackTrace is null',
42-
() async {
43-
final event = _getEvent();
44-
final processor = fixture.options.eventProcessors.first;
45-
final resultEvent = await processor.apply(event, Hint());
46-
47-
expect(resultEvent, equals(event));
48-
});
49-
50-
test(
51-
'Event processor does not add debug image if enableDartSymbolication is false',
52-
() async {
53-
fixture.options.enableDartSymbolication = false;
54-
final event = _getEvent();
55-
final processor = fixture.options.eventProcessors.first;
56-
final resultEvent = await processor.apply(event, Hint());
57-
58-
expect(resultEvent, equals(event));
59-
});
60-
61-
test('Event processor adds debug image when symbolication is needed',
62-
() async {
63-
final stackTrace = '''
15+
final platforms = [
16+
MockPlatform.iOS(),
17+
MockPlatform.macOS(),
18+
MockPlatform.android(),
19+
];
20+
21+
for (final platform in platforms) {
22+
setUp(() {
23+
fixture = Fixture();
24+
fixture.options.platformChecker =
25+
MockPlatformChecker(platform: platform);
26+
});
27+
28+
test('adds itself to sdk.integrations', () {
29+
expect(
30+
fixture.options.sdk.integrations.contains('loadDartImageIntegration'),
31+
true,
32+
);
33+
});
34+
35+
test('Event processor is added to options', () {
36+
expect(fixture.options.eventProcessors.length, 1);
37+
expect(
38+
fixture.options.eventProcessors.first.runtimeType.toString(),
39+
'_LoadImageIntegrationEventProcessor',
40+
);
41+
});
42+
43+
test(
44+
'Event processor does not add debug image if symbolication is not needed',
45+
() async {
46+
final event = _getEvent(needsSymbolication: false);
47+
final processor = fixture.options.eventProcessors.first;
48+
final resultEvent = await processor.apply(event, Hint());
49+
50+
expect(resultEvent, equals(event));
51+
});
52+
53+
test('Event processor does not add debug image if stackTrace is null',
54+
() async {
55+
final event = _getEvent();
56+
final processor = fixture.options.eventProcessors.first;
57+
final resultEvent = await processor.apply(event, Hint());
58+
59+
expect(resultEvent, equals(event));
60+
});
61+
62+
test(
63+
'Event processor does not add debug image if enableDartSymbolication is false',
64+
() async {
65+
fixture.options.enableDartSymbolication = false;
66+
final event = _getEvent();
67+
final processor = fixture.options.eventProcessors.first;
68+
final resultEvent = await processor.apply(event, Hint());
69+
70+
expect(resultEvent, equals(event));
71+
});
72+
73+
test('Event processor adds debug image when symbolication is needed',
74+
() async {
75+
final stackTrace = '''
6476
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
6577
build_id: 'b680cb890f9e3c12a24b172d050dec73'
6678
isolate_dso_base: 10000000
6779
''';
68-
SentryEvent event = _getEvent();
69-
final processor = fixture.options.eventProcessors.first;
70-
final resultEvent = await processor.apply(
71-
event, Hint()..set(hintRawStackTraceKey, stackTrace));
72-
73-
expect(resultEvent?.debugMeta?.images.length, 1);
74-
final debugImage = resultEvent?.debugMeta?.images.first;
75-
expect(debugImage?.debugId, isNotEmpty);
76-
expect(debugImage?.imageAddr, equals('0x10000000'));
77-
});
80+
SentryEvent event = _getEvent();
81+
final processor = fixture.options.eventProcessors.first;
82+
final resultEvent = await processor.apply(
83+
event, Hint()..set(hintRawStackTraceKey, stackTrace));
84+
85+
expect(resultEvent?.debugMeta?.images.length, 1);
86+
final debugImage = resultEvent?.debugMeta?.images.first;
87+
expect(debugImage?.debugId, isNotEmpty);
88+
expect(debugImage?.imageAddr, equals('0x10000000'));
89+
});
90+
}
7891
});
7992
}
8093

dart/test/mocks/mock_platform.dart

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class MockPlatform extends Platform with NoSuchMethodProvider {
1313
return MockPlatform(os: 'ios');
1414
}
1515

16+
factory MockPlatform.macOS() {
17+
return MockPlatform(os: 'macos');
18+
}
19+
1620
factory MockPlatform.linux() {
1721
return MockPlatform(os: 'linux');
1822
}

0 commit comments

Comments
 (0)