Commit 1f76f7f9 authored by Sam Rawlins's avatar Sam Rawlins Committed by Alexander Aprelev

Migrate to Mockito 3's anyNamed (#17632)

parent 20512d45
...@@ -15,9 +15,9 @@ void main() { ...@@ -15,9 +15,9 @@ void main() {
response = new MockHttpClientResponse(); response = new MockHttpClientResponse();
when(response.listen( when(response.listen(
typed(any), typed(any),
onDone: typed(any, named: 'onDone'), onDone: anyNamed('onDone'),
onError: typed(any, named: 'onError'), onError: anyNamed('onError'),
cancelOnError: typed(any, named: 'cancelOnError') cancelOnError: anyNamed('cancelOnError')
)).thenAnswer((Invocation invocation) { )).thenAnswer((Invocation invocation) {
final void Function(List<int>) onData = invocation.positionalArguments[0]; final void Function(List<int>) onData = invocation.positionalArguments[0];
final void Function(Object) onError = invocation.namedArguments[#onError]; final void Function(Object) onError = invocation.namedArguments[#onError];
...@@ -46,9 +46,9 @@ void main() { ...@@ -46,9 +46,9 @@ void main() {
test('forwards errors from HttpClientResponse', () async { test('forwards errors from HttpClientResponse', () async {
when(response.listen( when(response.listen(
typed(any), typed(any),
onDone: typed(any, named: 'onDone'), onDone: anyNamed('onDone'),
onError: typed(any, named: 'onError'), onError: anyNamed('onError'),
cancelOnError: typed(any, named: 'cancelOnError') cancelOnError: anyNamed('cancelOnError')
)).thenAnswer((Invocation invocation) { )).thenAnswer((Invocation invocation) {
final void Function(List<int>) onData = invocation.positionalArguments[0]; final void Function(List<int>) onData = invocation.positionalArguments[0];
final void Function(Object) onError = invocation.namedArguments[#onError]; final void Function(Object) onError = invocation.namedArguments[#onError];
...@@ -65,4 +65,4 @@ void main() { ...@@ -65,4 +65,4 @@ void main() {
}); });
} }
class MockHttpClientResponse extends Mock implements HttpClientResponse {} class MockHttpClientResponse extends Mock implements HttpClientResponse {}
\ No newline at end of file
...@@ -51,8 +51,8 @@ void main() { ...@@ -51,8 +51,8 @@ void main() {
when(process.exitCode).thenAnswer((_) => new Future<int>.value(0)); when(process.exitCode).thenAnswer((_) => new Future<int>.value(0));
when(mockProcessManager.start( when(mockProcessManager.start(
<String>['git', 'branch', '-r'], <String>['git', 'branch', '-r'],
workingDirectory: typed(any, named: 'workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
environment: typed(any, named: 'environment'))) environment: anyNamed('environment')))
.thenAnswer((_) => new Future<Process>.value(process)); .thenAnswer((_) => new Future<Process>.value(process));
final ChannelCommand command = new ChannelCommand(); final ChannelCommand command = new ChannelCommand();
...@@ -60,8 +60,8 @@ void main() { ...@@ -60,8 +60,8 @@ void main() {
await runner.run(<String>['channel']); await runner.run(<String>['channel']);
verify(mockProcessManager.start(<String>['git', 'branch', '-r'], verify(mockProcessManager.start(<String>['git', 'branch', '-r'],
workingDirectory: typed(any, named: 'workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
environment: typed(any, named: 'environment'))).called(1); environment: anyNamed('environment'))).called(1);
expect(testLogger.errorText, hasLength(0)); expect(testLogger.errorText, hasLength(0));
...@@ -81,4 +81,4 @@ void main() { ...@@ -81,4 +81,4 @@ void main() {
class MockProcessManager extends Mock implements ProcessManager {} class MockProcessManager extends Mock implements ProcessManager {}
class MockProcess extends Mock implements Process {} class MockProcess extends Mock implements Process {}
\ No newline at end of file
...@@ -206,7 +206,7 @@ void main() { ...@@ -206,7 +206,7 @@ void main() {
verifyNever(mockProcessManager.run( verifyNever(mockProcessManager.run(
argThat(containsAllInOrder(<String>['pod', 'install'])), argThat(containsAllInOrder(<String>['pod', 'install'])),
workingDirectory: any, workingDirectory: any,
environment: typed<Map<String, String>>(any, named: 'environment'), environment: anyNamed('environment'),
)); ));
expect(testLogger.errorText, contains('not installed')); expect(testLogger.errorText, contains('not installed'));
expect(testLogger.errorText, contains('Skipping pod install')); expect(testLogger.errorText, contains('Skipping pod install'));
...@@ -228,7 +228,7 @@ void main() { ...@@ -228,7 +228,7 @@ void main() {
verifyNever(mockProcessManager.run( verifyNever(mockProcessManager.run(
argThat(containsAllInOrder(<String>['pod', 'install'])), argThat(containsAllInOrder(<String>['pod', 'install'])),
workingDirectory: any, workingDirectory: any,
environment: typed<Map<String, String>>(any, named: 'environment'), environment: anyNamed('environment'),
)); ));
} }
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -439,7 +439,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by ...@@ -439,7 +439,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
verifyNever(mockProcessManager.run( verifyNever(mockProcessManager.run(
argThat(containsAllInOrder(<String>['pod', 'install'])), argThat(containsAllInOrder(<String>['pod', 'install'])),
workingDirectory: any, workingDirectory: any,
environment: typed<Map<String, String>>(any, named: 'environment'), environment: anyNamed('environment'),
)); ));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fs, FileSystem: () => fs,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment