Have runAsyncChecked throw a ProcessException instead of a String. (#22710)
This commit is contained in:
@@ -2,12 +2,28 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
||||
void main() {
|
||||
group('process exceptions', () {
|
||||
ProcessManager mockProcessManager;
|
||||
|
||||
setUp(() {
|
||||
mockProcessManager = MockProcessManager();
|
||||
});
|
||||
|
||||
testUsingContext('runCheckedAsync exceptions should be ProcessException objects', () async {
|
||||
when(mockProcessManager.run(<String>['false']))
|
||||
.thenAnswer((Invocation invocation) => Future<ProcessResult>.value(ProcessResult(0, 1, '', '')));
|
||||
expect(() async => await runCheckedAsync(<String>['false']), throwsA(isInstanceOf<ProcessException>()));
|
||||
}, overrides: <Type, Generator>{ProcessManager: () => mockProcessManager});
|
||||
});
|
||||
group('shutdownHooks', () {
|
||||
testUsingContext('runInExpectedOrder', () async {
|
||||
int i = 1;
|
||||
@@ -41,3 +57,5 @@ void main() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class MockProcessManager extends Mock implements ProcessManager {}
|
||||
|
||||
Reference in New Issue
Block a user