Skip to content

Commit 3263ffd

Browse files
committed
fix tests
1 parent a842788 commit 3263ffd

19 files changed

Lines changed: 328 additions & 147 deletions

dart/test/debug_image_extractor_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ isolate_dso_base: 10000000
112112

113113
class Fixture {
114114
DebugImageExtractor getSut({required MockPlatform platform}) {
115-
final options = defaultTestOptions()
116-
..platformChecker = MockPlatformChecker(platform: platform);
115+
final options = defaultTestOptions(MockPlatformChecker(platform: platform));
117116
return DebugImageExtractor(options);
118117
}
119118
}

dart/test/event_processor/enricher/io_enricher_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,8 @@ class Fixture {
186186
bool hasNativeIntegration = false,
187187
bool includePii = false,
188188
}) {
189-
final options = defaultTestOptions()
190-
..platformChecker =
191-
MockPlatformChecker(hasNativeIntegration: hasNativeIntegration)
189+
final options = defaultTestOptions(
190+
MockPlatformChecker(hasNativeIntegration: hasNativeIntegration))
192191
..sendDefaultPii = includePii;
193192

194193
return IoEnricherEventProcessor(options);

dart/test/event_processor/enricher/web_enricher_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ void main() {
202202

203203
class Fixture {
204204
WebEnricherEventProcessor getSut() {
205-
final options = defaultTestOptions()
206-
..platformChecker = MockPlatformChecker(hasNativeIntegration: false);
205+
final options =
206+
defaultTestOptions(MockPlatformChecker(hasNativeIntegration: false));
207207
return enricherEventProcessor(options) as WebEnricherEventProcessor;
208208
}
209209
}

dart/test/sentry_client_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,8 +1896,8 @@ class Fixture {
18961896
final recorder = MockClientReportRecorder();
18971897
final transport = MockTransport();
18981898

1899-
final options = defaultTestOptions()
1900-
..platformChecker = MockPlatformChecker(platform: MockPlatform.iOS());
1899+
final options =
1900+
defaultTestOptions(MockPlatformChecker(platform: MockPlatform.iOS()));
19011901

19021902
late SentryTransactionContext _context;
19031903
late SentryTracer tracer;

dart/test/sentry_test.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,7 @@ void main() {
372372
});
373373

374374
test('options.environment debug', () async {
375-
final sentryOptions = defaultTestOptions()
376-
..platformChecker = FakePlatformChecker.debugMode();
375+
final sentryOptions = defaultTestOptions(FakePlatformChecker.debugMode());
377376
await Sentry.init(
378377
(options) {
379378
options.dsn = fakeDsn;
@@ -385,8 +384,7 @@ void main() {
385384
});
386385

387386
test('options.environment profile', () async {
388-
final sentryOptions = defaultTestOptions()
389-
..platformChecker = FakePlatformChecker.profileMode();
387+
final sentryOptions = defaultTestOptions(FakePlatformChecker.profileMode());
390388

391389
await Sentry.init(
392390
(options) {
@@ -399,8 +397,7 @@ void main() {
399397
});
400398

401399
test('options.environment production (defaultEnvironment)', () async {
402-
final sentryOptions = defaultTestOptions()
403-
..platformChecker = FakePlatformChecker.releaseMode();
400+
final sentryOptions = defaultTestOptions(FakePlatformChecker.releaseMode());
404401
await Sentry.init(
405402
(options) {
406403
options.dsn = fakeDsn;
@@ -412,8 +409,7 @@ void main() {
412409
});
413410

414411
test('options.logger is set by setting the debug flag', () async {
415-
final sentryOptions = defaultTestOptions()
416-
..platformChecker = FakePlatformChecker.debugMode();
412+
final sentryOptions = defaultTestOptions(FakePlatformChecker.debugMode());
417413

418414
await Sentry.init(
419415
(options) {

dart/test/stack_trace_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ class Fixture {
299299
bool considerInAppFramesByDefault = true,
300300
bool isWeb = false,
301301
}) {
302-
final options = defaultTestOptions()
303-
..platformChecker = MockPlatformChecker(isWebValue: isWeb);
302+
final options = defaultTestOptions(MockPlatformChecker(isWebValue: isWeb));
304303
inAppIncludes.forEach(options.addInAppInclude);
305304
inAppExcludes.forEach(options.addInAppExclude);
306305
options.considerInAppFramesByDefault = considerInAppFramesByDefault;

dart/test/test_utils.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ const String _testDsnWithPath =
1818
const String _testDsnWithPort =
1919
'https://public:[email protected]:8888/1';
2020

21-
SentryOptions defaultTestOptions() {
22-
return SentryOptions(dsn: testDsn)..automatedTestMode = true;
21+
SentryOptions defaultTestOptions([PlatformChecker? checker]) {
22+
return SentryOptions(dsn: testDsn, checker: checker)
23+
..automatedTestMode = true;
2324
}
2425

2526
void testHeaders(

flutter/test/event_processor/flutter_enricher_event_processor_test.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,9 @@ void main() {
368368

369369
testWidgets('$FlutterEnricherEventProcessor gets added on init',
370370
(tester) async {
371-
final sentryOptions = defaultTestOptions()
372-
// use a mockplatform checker so that we don't need to mock platform channels
373-
..platformChecker = MockPlatformChecker(hasNativeIntegration: false);
371+
// use a mockplatform checker so that we don't need to mock platform channels
372+
final sentryOptions =
373+
defaultTestOptions(MockPlatformChecker(hasNativeIntegration: false));
374374

375375
loadTestPackage();
376376
await SentryFlutter.init((options) {
@@ -417,8 +417,7 @@ class Fixture {
417417
hasNativeIntegration: hasNativeIntegration,
418418
);
419419

420-
final options = defaultTestOptions()
421-
..platformChecker = platformChecker
420+
final options = defaultTestOptions(platformChecker)
422421
..reportPackages = reportPackages;
423422
final customizedOptions = optionsBuilder?.call(options) ?? options;
424423
return FlutterEnricherEventProcessor(customizedOptions);

flutter/test/initialization_test.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,22 @@ import 'mocks.dart';
1010
// https://github.com/getsentry/sentry-dart/issues/508
1111
// There are no asserts, test are succesfull if no exceptions are thrown.
1212
void main() {
13-
setUp(() async {
14-
await Sentry.close();
15-
});
13+
final native = NativeChannelFixture();
1614

1715
void optionsInitializer(SentryFlutterOptions options) {
18-
options.dsn = fakeDsn;
19-
options.automatedTestMode = true;
20-
2116
// LoadReleaseIntegration throws because package_info channel is not available
2217
options.removeIntegration(
2318
options.integrations.firstWhere((i) => i is LoadReleaseIntegration));
2419
}
2520

2621
test('async re-initilization', () async {
27-
await SentryFlutter.init(optionsInitializer);
22+
await SentryFlutter.init(optionsInitializer,
23+
options: defaultTestOptions()..methodChannel = native.channel);
2824

2925
await Sentry.close();
3026

31-
await SentryFlutter.init(optionsInitializer);
27+
await SentryFlutter.init(optionsInitializer,
28+
options: defaultTestOptions()..methodChannel = native.channel);
3229

3330
await Sentry.close();
3431
});

flutter/test/integrations/debug_print_integration_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ class Fixture {
9494
bool debug = false,
9595
bool enablePrintBreadcrumbs = true,
9696
}) {
97-
return defaultTestOptions()
98-
..platformChecker = MockPlatformChecker(isDebug: debug)
97+
return defaultTestOptions(MockPlatformChecker(isDebug: debug))
9998
..enablePrintBreadcrumbs = enablePrintBreadcrumbs;
10099
}
101100

0 commit comments

Comments
 (0)