use throwsA matcher instead of try-catch-fail (#82290)
This commit is contained in:
committed by
GitHub
parent
e621ebfb34
commit
4881b33515
@@ -288,20 +288,17 @@ void main() {
|
||||
processManager: FakeProcessManager.any(),
|
||||
logger: logger,
|
||||
);
|
||||
try {
|
||||
await cache.updateAll(<DevelopmentArtifact>{
|
||||
null,
|
||||
});
|
||||
fail('Mock thrown exception expected');
|
||||
} on Exception {
|
||||
verify(artifact1.update(any, any, any, any));
|
||||
// Don't continue when retrieval fails.
|
||||
verifyNever(artifact2.update(any, any, any, any));
|
||||
expect(
|
||||
logger.errorText,
|
||||
contains('https://flutter.dev/community/china'),
|
||||
);
|
||||
}
|
||||
await expectLater(
|
||||
() => cache.updateAll(<DevelopmentArtifact>{null}),
|
||||
throwsA(isA<Exception>()),
|
||||
);
|
||||
verify(artifact1.update(any, any, any, any));
|
||||
// Don't continue when retrieval fails.
|
||||
verifyNever(artifact2.update(any, any, any, any));
|
||||
expect(
|
||||
logger.errorText,
|
||||
contains('https://flutter.dev/community/china'),
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('Invalid URI for FLUTTER_STORAGE_BASE_URL throws ToolExit', () async {
|
||||
|
||||
@@ -210,24 +210,23 @@ void main() {
|
||||
throwToolExit('fail');
|
||||
}
|
||||
);
|
||||
try {
|
||||
await flutterCommand.run();
|
||||
fail('Mock should make this fail');
|
||||
} on ToolExit {
|
||||
expect(usage.events, <TestUsageEvent>[
|
||||
const TestUsageEvent(
|
||||
'tool-command-result',
|
||||
'dummy',
|
||||
label: 'fail',
|
||||
),
|
||||
const TestUsageEvent(
|
||||
'tool-command-max-rss',
|
||||
'dummy',
|
||||
label: 'fail',
|
||||
value: 10,
|
||||
),
|
||||
]);
|
||||
}
|
||||
await expectLater(
|
||||
() => flutterCommand.run(),
|
||||
throwsA(isA<ToolExit>()),
|
||||
);
|
||||
expect(usage.events, <TestUsageEvent>[
|
||||
const TestUsageEvent(
|
||||
'tool-command-result',
|
||||
'dummy',
|
||||
label: 'fail',
|
||||
),
|
||||
const TestUsageEvent(
|
||||
'tool-command-max-rss',
|
||||
'dummy',
|
||||
label: 'fail',
|
||||
value: 10,
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
test('FlutterCommandResult.success()', () async {
|
||||
@@ -435,18 +434,18 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
try {
|
||||
await flutterCommand.run();
|
||||
fail('Mock should make this fail');
|
||||
} on ToolExit {
|
||||
expect(usage.timings, contains(
|
||||
const TestTimingEvent(
|
||||
'flutter',
|
||||
'dummy',
|
||||
Duration(milliseconds: 1000),
|
||||
label: 'fail',
|
||||
)));
|
||||
}
|
||||
await expectLater(
|
||||
() => flutterCommand.run(),
|
||||
throwsA(isA<ToolExit>()),
|
||||
);
|
||||
expect(usage.timings, contains(
|
||||
const TestTimingEvent(
|
||||
'flutter',
|
||||
'dummy',
|
||||
Duration(milliseconds: 1000),
|
||||
label: 'fail',
|
||||
),
|
||||
));
|
||||
});
|
||||
|
||||
testUsingContext('reports null safety analytics when reportNullSafety is true', () async {
|
||||
|
||||
Reference in New Issue
Block a user