use throwsA matcher instead of try-catch-fail (#82290)

This commit is contained in:
Alexandre Ardhuin
2021-05-12 08:34:02 +02:00
committed by GitHub
parent e621ebfb34
commit 4881b33515
6 changed files with 168 additions and 154 deletions

View File

@@ -274,14 +274,14 @@ void main() {
);
await creator.initializeRepo();
try {
await creator.createArchive();
fail('failed to throw');
} on Exception catch (e) {
expect(e is PreparePackageException, true);
final PreparePackageException exception = e as PreparePackageException;
expect(exception.message, contains('The binary $binPath was not codesigned!'));
}
await expectLater(
() => creator.createArchive(),
throwsA(isA<PreparePackageException>().having(
(PreparePackageException exception) => exception.message,
'message',
contains('The binary $binPath was not codesigned!'),
)),
);
}, skip: !platform.isMacOS);
});