From 8951c892153a7a8c5f2f5da6fc987a889622b768 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sat, 9 Dec 2023 16:18:43 +0100 Subject: [PATCH] test(dynamite_end_to_end_test): test the clients generated by dynamite Signed-off-by: Nikolas Rimikis --- cspell.json | 1 + .../dynamite_end_to_end_test/pubspec.yaml | 1 + .../test/http_client_mock.dart | 9 + .../test/http_client_mock.mocks.dart | 1932 +++++++++++++++++ .../test/parameters_test.dart | 124 ++ tool/find-dart-io-usage.sh | 2 +- 6 files changed, 2068 insertions(+), 1 deletion(-) create mode 100644 packages/dynamite/dynamite_end_to_end_test/test/http_client_mock.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/test/http_client_mock.mocks.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/test/parameters_test.dart diff --git a/cspell.json b/cspell.json index 1ee6fa6cd7b..e7dca8c3e3f 100644 --- a/cspell.json +++ b/cspell.json @@ -8,6 +8,7 @@ ], "ignorePaths": [ "**.svg", + "**.mocks.dart", "**/assets", "**/l10n/!(en.arb)", "external", diff --git a/packages/dynamite/dynamite_end_to_end_test/pubspec.yaml b/packages/dynamite/dynamite_end_to_end_test/pubspec.yaml index bcd4e39a3f0..744a9f76ba3 100644 --- a/packages/dynamite/dynamite_end_to_end_test/pubspec.yaml +++ b/packages/dynamite/dynamite_end_to_end_test/pubspec.yaml @@ -25,6 +25,7 @@ dev_dependencies: git: url: https://github.com/nextcloud/neon path: packages/dynamite/dynamite + mockito: ^5.4.3 neon_lints: git: url: https://github.com/nextcloud/neon diff --git a/packages/dynamite/dynamite_end_to_end_test/test/http_client_mock.dart b/packages/dynamite/dynamite_end_to_end_test/test/http_client_mock.dart new file mode 100644 index 00000000000..0afeddd140e --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/test/http_client_mock.dart @@ -0,0 +1,9 @@ +@GenerateNiceMocks([ + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), +]) + +import 'package:mockito/annotations.dart'; +import 'package:universal_io/io.dart'; diff --git a/packages/dynamite/dynamite_end_to_end_test/test/http_client_mock.mocks.dart b/packages/dynamite/dynamite_end_to_end_test/test/http_client_mock.mocks.dart new file mode 100644 index 00000000000..f3f1f4327c5 --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/test/http_client_mock.mocks.dart @@ -0,0 +1,1932 @@ +// Mocks generated by Mockito 5.4.3 from annotations +// in dynamite_end_to_end_test/test/http_client_mock.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i4; +import 'dart:convert' as _i3; +import 'dart:io' as _i2; + +import 'package:mockito/mockito.dart' as _i1; +import 'package:mockito/src/dummies.dart' as _i5; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakeDuration_0 extends _i1.SmartFake implements Duration { + _FakeDuration_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeHttpClientRequest_1 extends _i1.SmartFake implements _i2.HttpClientRequest { + _FakeHttpClientRequest_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeUri_2 extends _i1.SmartFake implements Uri { + _FakeUri_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeHttpHeaders_3 extends _i1.SmartFake implements _i2.HttpHeaders { + _FakeHttpHeaders_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeHttpClientResponse_4 extends _i1.SmartFake implements _i2.HttpClientResponse { + _FakeHttpClientResponse_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeEncoding_5 extends _i1.SmartFake implements _i3.Encoding { + _FakeEncoding_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeSocket_6 extends _i1.SmartFake implements _i2.Socket { + _FakeSocket_6( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeStreamSubscription_7 extends _i1.SmartFake implements _i4.StreamSubscription { + _FakeStreamSubscription_7( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeFuture_8 extends _i1.SmartFake implements _i4.Future { + _FakeFuture_8( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [HttpClient]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockHttpClient extends _i1.Mock implements _i2.HttpClient { + @override + Duration get idleTimeout => (super.noSuchMethod( + Invocation.getter(#idleTimeout), + returnValue: _FakeDuration_0( + this, + Invocation.getter(#idleTimeout), + ), + returnValueForMissingStub: _FakeDuration_0( + this, + Invocation.getter(#idleTimeout), + ), + ) as Duration); + + @override + set idleTimeout(Duration? _idleTimeout) => super.noSuchMethod( + Invocation.setter( + #idleTimeout, + _idleTimeout, + ), + returnValueForMissingStub: null, + ); + + @override + set connectionTimeout(Duration? _connectionTimeout) => super.noSuchMethod( + Invocation.setter( + #connectionTimeout, + _connectionTimeout, + ), + returnValueForMissingStub: null, + ); + + @override + set maxConnectionsPerHost(int? _maxConnectionsPerHost) => super.noSuchMethod( + Invocation.setter( + #maxConnectionsPerHost, + _maxConnectionsPerHost, + ), + returnValueForMissingStub: null, + ); + + @override + bool get autoUncompress => (super.noSuchMethod( + Invocation.getter(#autoUncompress), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + set autoUncompress(bool? _autoUncompress) => super.noSuchMethod( + Invocation.setter( + #autoUncompress, + _autoUncompress, + ), + returnValueForMissingStub: null, + ); + + @override + set userAgent(String? _userAgent) => super.noSuchMethod( + Invocation.setter( + #userAgent, + _userAgent, + ), + returnValueForMissingStub: null, + ); + + @override + set authenticate( + _i4.Future Function( + Uri, + String, + String?, + )? f) => + super.noSuchMethod( + Invocation.setter( + #authenticate, + f, + ), + returnValueForMissingStub: null, + ); + + @override + set connectionFactory( + _i4.Future<_i2.ConnectionTask<_i2.Socket>> Function( + Uri, + String?, + int?, + )? f) => + super.noSuchMethod( + Invocation.setter( + #connectionFactory, + f, + ), + returnValueForMissingStub: null, + ); + + @override + set findProxy(String Function(Uri)? f) => super.noSuchMethod( + Invocation.setter( + #findProxy, + f, + ), + returnValueForMissingStub: null, + ); + + @override + set authenticateProxy( + _i4.Future Function( + String, + int, + String, + String?, + )? f) => + super.noSuchMethod( + Invocation.setter( + #authenticateProxy, + f, + ), + returnValueForMissingStub: null, + ); + + @override + set badCertificateCallback( + bool Function( + _i2.X509Certificate, + String, + int, + )? callback) => + super.noSuchMethod( + Invocation.setter( + #badCertificateCallback, + callback, + ), + returnValueForMissingStub: null, + ); + + @override + set keyLog(dynamic Function(String)? callback) => super.noSuchMethod( + Invocation.setter( + #keyLog, + callback, + ), + returnValueForMissingStub: null, + ); + + @override + _i4.Future<_i2.HttpClientRequest> open( + String? method, + String? host, + int? port, + String? path, + ) => + (super.noSuchMethod( + Invocation.method( + #open, + [ + method, + host, + port, + path, + ], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #open, + [ + method, + host, + port, + path, + ], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #open, + [ + method, + host, + port, + path, + ], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> openUrl( + String? method, + Uri? url, + ) => + (super.noSuchMethod( + Invocation.method( + #openUrl, + [ + method, + url, + ], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #openUrl, + [ + method, + url, + ], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #openUrl, + [ + method, + url, + ], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> get( + String? host, + int? port, + String? path, + ) => + (super.noSuchMethod( + Invocation.method( + #get, + [ + host, + port, + path, + ], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #get, + [ + host, + port, + path, + ], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #get, + [ + host, + port, + path, + ], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> getUrl(Uri? url) => (super.noSuchMethod( + Invocation.method( + #getUrl, + [url], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #getUrl, + [url], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #getUrl, + [url], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> post( + String? host, + int? port, + String? path, + ) => + (super.noSuchMethod( + Invocation.method( + #post, + [ + host, + port, + path, + ], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #post, + [ + host, + port, + path, + ], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #post, + [ + host, + port, + path, + ], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> postUrl(Uri? url) => (super.noSuchMethod( + Invocation.method( + #postUrl, + [url], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #postUrl, + [url], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #postUrl, + [url], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> put( + String? host, + int? port, + String? path, + ) => + (super.noSuchMethod( + Invocation.method( + #put, + [ + host, + port, + path, + ], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #put, + [ + host, + port, + path, + ], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #put, + [ + host, + port, + path, + ], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> putUrl(Uri? url) => (super.noSuchMethod( + Invocation.method( + #putUrl, + [url], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #putUrl, + [url], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #putUrl, + [url], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> delete( + String? host, + int? port, + String? path, + ) => + (super.noSuchMethod( + Invocation.method( + #delete, + [ + host, + port, + path, + ], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #delete, + [ + host, + port, + path, + ], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #delete, + [ + host, + port, + path, + ], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> deleteUrl(Uri? url) => (super.noSuchMethod( + Invocation.method( + #deleteUrl, + [url], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #deleteUrl, + [url], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #deleteUrl, + [url], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> patch( + String? host, + int? port, + String? path, + ) => + (super.noSuchMethod( + Invocation.method( + #patch, + [ + host, + port, + path, + ], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #patch, + [ + host, + port, + path, + ], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #patch, + [ + host, + port, + path, + ], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> patchUrl(Uri? url) => (super.noSuchMethod( + Invocation.method( + #patchUrl, + [url], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #patchUrl, + [url], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #patchUrl, + [url], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> head( + String? host, + int? port, + String? path, + ) => + (super.noSuchMethod( + Invocation.method( + #head, + [ + host, + port, + path, + ], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #head, + [ + host, + port, + path, + ], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #head, + [ + host, + port, + path, + ], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + _i4.Future<_i2.HttpClientRequest> headUrl(Uri? url) => (super.noSuchMethod( + Invocation.method( + #headUrl, + [url], + ), + returnValue: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #headUrl, + [url], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientRequest>.value(_FakeHttpClientRequest_1( + this, + Invocation.method( + #headUrl, + [url], + ), + )), + ) as _i4.Future<_i2.HttpClientRequest>); + + @override + void addCredentials( + Uri? url, + String? realm, + _i2.HttpClientCredentials? credentials, + ) => + super.noSuchMethod( + Invocation.method( + #addCredentials, + [ + url, + realm, + credentials, + ], + ), + returnValueForMissingStub: null, + ); + + @override + void addProxyCredentials( + String? host, + int? port, + String? realm, + _i2.HttpClientCredentials? credentials, + ) => + super.noSuchMethod( + Invocation.method( + #addProxyCredentials, + [ + host, + port, + realm, + credentials, + ], + ), + returnValueForMissingStub: null, + ); + + @override + void close({bool? force = false}) => super.noSuchMethod( + Invocation.method( + #close, + [], + {#force: force}, + ), + returnValueForMissingStub: null, + ); +} + +/// A class which mocks [HttpClientRequest]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockHttpClientRequest extends _i1.Mock implements _i2.HttpClientRequest { + @override + bool get persistentConnection => (super.noSuchMethod( + Invocation.getter(#persistentConnection), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + set persistentConnection(bool? _persistentConnection) => super.noSuchMethod( + Invocation.setter( + #persistentConnection, + _persistentConnection, + ), + returnValueForMissingStub: null, + ); + + @override + bool get followRedirects => (super.noSuchMethod( + Invocation.getter(#followRedirects), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + set followRedirects(bool? _followRedirects) => super.noSuchMethod( + Invocation.setter( + #followRedirects, + _followRedirects, + ), + returnValueForMissingStub: null, + ); + + @override + int get maxRedirects => (super.noSuchMethod( + Invocation.getter(#maxRedirects), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + set maxRedirects(int? _maxRedirects) => super.noSuchMethod( + Invocation.setter( + #maxRedirects, + _maxRedirects, + ), + returnValueForMissingStub: null, + ); + + @override + int get contentLength => (super.noSuchMethod( + Invocation.getter(#contentLength), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + set contentLength(int? _contentLength) => super.noSuchMethod( + Invocation.setter( + #contentLength, + _contentLength, + ), + returnValueForMissingStub: null, + ); + + @override + bool get bufferOutput => (super.noSuchMethod( + Invocation.getter(#bufferOutput), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + set bufferOutput(bool? _bufferOutput) => super.noSuchMethod( + Invocation.setter( + #bufferOutput, + _bufferOutput, + ), + returnValueForMissingStub: null, + ); + + @override + String get method => (super.noSuchMethod( + Invocation.getter(#method), + returnValue: _i5.dummyValue( + this, + Invocation.getter(#method), + ), + returnValueForMissingStub: _i5.dummyValue( + this, + Invocation.getter(#method), + ), + ) as String); + + @override + Uri get uri => (super.noSuchMethod( + Invocation.getter(#uri), + returnValue: _FakeUri_2( + this, + Invocation.getter(#uri), + ), + returnValueForMissingStub: _FakeUri_2( + this, + Invocation.getter(#uri), + ), + ) as Uri); + + @override + _i2.HttpHeaders get headers => (super.noSuchMethod( + Invocation.getter(#headers), + returnValue: _FakeHttpHeaders_3( + this, + Invocation.getter(#headers), + ), + returnValueForMissingStub: _FakeHttpHeaders_3( + this, + Invocation.getter(#headers), + ), + ) as _i2.HttpHeaders); + + @override + List<_i2.Cookie> get cookies => (super.noSuchMethod( + Invocation.getter(#cookies), + returnValue: <_i2.Cookie>[], + returnValueForMissingStub: <_i2.Cookie>[], + ) as List<_i2.Cookie>); + + @override + _i4.Future<_i2.HttpClientResponse> get done => (super.noSuchMethod( + Invocation.getter(#done), + returnValue: _i4.Future<_i2.HttpClientResponse>.value(_FakeHttpClientResponse_4( + this, + Invocation.getter(#done), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientResponse>.value(_FakeHttpClientResponse_4( + this, + Invocation.getter(#done), + )), + ) as _i4.Future<_i2.HttpClientResponse>); + + @override + _i3.Encoding get encoding => (super.noSuchMethod( + Invocation.getter(#encoding), + returnValue: _FakeEncoding_5( + this, + Invocation.getter(#encoding), + ), + returnValueForMissingStub: _FakeEncoding_5( + this, + Invocation.getter(#encoding), + ), + ) as _i3.Encoding); + + @override + set encoding(_i3.Encoding? _encoding) => super.noSuchMethod( + Invocation.setter( + #encoding, + _encoding, + ), + returnValueForMissingStub: null, + ); + + @override + _i4.Future<_i2.HttpClientResponse> close() => (super.noSuchMethod( + Invocation.method( + #close, + [], + ), + returnValue: _i4.Future<_i2.HttpClientResponse>.value(_FakeHttpClientResponse_4( + this, + Invocation.method( + #close, + [], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientResponse>.value(_FakeHttpClientResponse_4( + this, + Invocation.method( + #close, + [], + ), + )), + ) as _i4.Future<_i2.HttpClientResponse>); + + @override + void abort([ + Object? exception, + StackTrace? stackTrace, + ]) => + super.noSuchMethod( + Invocation.method( + #abort, + [ + exception, + stackTrace, + ], + ), + returnValueForMissingStub: null, + ); + + @override + void add(List? data) => super.noSuchMethod( + Invocation.method( + #add, + [data], + ), + returnValueForMissingStub: null, + ); + + @override + void write(Object? object) => super.noSuchMethod( + Invocation.method( + #write, + [object], + ), + returnValueForMissingStub: null, + ); + + @override + void writeAll( + Iterable? objects, [ + String? separator = r'', + ]) => + super.noSuchMethod( + Invocation.method( + #writeAll, + [ + objects, + separator, + ], + ), + returnValueForMissingStub: null, + ); + + @override + void writeln([Object? object = r'']) => super.noSuchMethod( + Invocation.method( + #writeln, + [object], + ), + returnValueForMissingStub: null, + ); + + @override + void writeCharCode(int? charCode) => super.noSuchMethod( + Invocation.method( + #writeCharCode, + [charCode], + ), + returnValueForMissingStub: null, + ); + + @override + void addError( + Object? error, [ + StackTrace? stackTrace, + ]) => + super.noSuchMethod( + Invocation.method( + #addError, + [ + error, + stackTrace, + ], + ), + returnValueForMissingStub: null, + ); + + @override + _i4.Future addStream(_i4.Stream>? stream) => (super.noSuchMethod( + Invocation.method( + #addStream, + [stream], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future flush() => (super.noSuchMethod( + Invocation.method( + #flush, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); +} + +/// A class which mocks [HttpClientResponse]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockHttpClientResponse extends _i1.Mock implements _i2.HttpClientResponse { + @override + int get statusCode => (super.noSuchMethod( + Invocation.getter(#statusCode), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + String get reasonPhrase => (super.noSuchMethod( + Invocation.getter(#reasonPhrase), + returnValue: _i5.dummyValue( + this, + Invocation.getter(#reasonPhrase), + ), + returnValueForMissingStub: _i5.dummyValue( + this, + Invocation.getter(#reasonPhrase), + ), + ) as String); + + @override + int get contentLength => (super.noSuchMethod( + Invocation.getter(#contentLength), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + _i2.HttpClientResponseCompressionState get compressionState => (super.noSuchMethod( + Invocation.getter(#compressionState), + returnValue: _i2.HttpClientResponseCompressionState.notCompressed, + returnValueForMissingStub: _i2.HttpClientResponseCompressionState.notCompressed, + ) as _i2.HttpClientResponseCompressionState); + + @override + bool get persistentConnection => (super.noSuchMethod( + Invocation.getter(#persistentConnection), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + bool get isRedirect => (super.noSuchMethod( + Invocation.getter(#isRedirect), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + List<_i2.RedirectInfo> get redirects => (super.noSuchMethod( + Invocation.getter(#redirects), + returnValue: <_i2.RedirectInfo>[], + returnValueForMissingStub: <_i2.RedirectInfo>[], + ) as List<_i2.RedirectInfo>); + + @override + _i2.HttpHeaders get headers => (super.noSuchMethod( + Invocation.getter(#headers), + returnValue: _FakeHttpHeaders_3( + this, + Invocation.getter(#headers), + ), + returnValueForMissingStub: _FakeHttpHeaders_3( + this, + Invocation.getter(#headers), + ), + ) as _i2.HttpHeaders); + + @override + List<_i2.Cookie> get cookies => (super.noSuchMethod( + Invocation.getter(#cookies), + returnValue: <_i2.Cookie>[], + returnValueForMissingStub: <_i2.Cookie>[], + ) as List<_i2.Cookie>); + + @override + bool get isBroadcast => (super.noSuchMethod( + Invocation.getter(#isBroadcast), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + _i4.Future get length => (super.noSuchMethod( + Invocation.getter(#length), + returnValue: _i4.Future.value(0), + returnValueForMissingStub: _i4.Future.value(0), + ) as _i4.Future); + + @override + _i4.Future get isEmpty => (super.noSuchMethod( + Invocation.getter(#isEmpty), + returnValue: _i4.Future.value(false), + returnValueForMissingStub: _i4.Future.value(false), + ) as _i4.Future); + + @override + _i4.Future> get first => (super.noSuchMethod( + Invocation.getter(#first), + returnValue: _i4.Future>.value([]), + returnValueForMissingStub: _i4.Future>.value([]), + ) as _i4.Future>); + + @override + _i4.Future> get last => (super.noSuchMethod( + Invocation.getter(#last), + returnValue: _i4.Future>.value([]), + returnValueForMissingStub: _i4.Future>.value([]), + ) as _i4.Future>); + + @override + _i4.Future> get single => (super.noSuchMethod( + Invocation.getter(#single), + returnValue: _i4.Future>.value([]), + returnValueForMissingStub: _i4.Future>.value([]), + ) as _i4.Future>); + + @override + _i4.Future<_i2.HttpClientResponse> redirect([ + String? method, + Uri? url, + bool? followLoops, + ]) => + (super.noSuchMethod( + Invocation.method( + #redirect, + [ + method, + url, + followLoops, + ], + ), + returnValue: _i4.Future<_i2.HttpClientResponse>.value(_FakeHttpClientResponse_4( + this, + Invocation.method( + #redirect, + [ + method, + url, + followLoops, + ], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.HttpClientResponse>.value(_FakeHttpClientResponse_4( + this, + Invocation.method( + #redirect, + [ + method, + url, + followLoops, + ], + ), + )), + ) as _i4.Future<_i2.HttpClientResponse>); + + @override + _i4.Future<_i2.Socket> detachSocket() => (super.noSuchMethod( + Invocation.method( + #detachSocket, + [], + ), + returnValue: _i4.Future<_i2.Socket>.value(_FakeSocket_6( + this, + Invocation.method( + #detachSocket, + [], + ), + )), + returnValueForMissingStub: _i4.Future<_i2.Socket>.value(_FakeSocket_6( + this, + Invocation.method( + #detachSocket, + [], + ), + )), + ) as _i4.Future<_i2.Socket>); + + @override + _i4.Stream> asBroadcastStream({ + void Function(_i4.StreamSubscription>)? onListen, + void Function(_i4.StreamSubscription>)? onCancel, + }) => + (super.noSuchMethod( + Invocation.method( + #asBroadcastStream, + [], + { + #onListen: onListen, + #onCancel: onCancel, + }, + ), + returnValue: _i4.Stream>.empty(), + returnValueForMissingStub: _i4.Stream>.empty(), + ) as _i4.Stream>); + + @override + _i4.StreamSubscription> listen( + void Function(List)? onData, { + Function? onError, + void Function()? onDone, + bool? cancelOnError, + }) => + (super.noSuchMethod( + Invocation.method( + #listen, + [onData], + { + #onError: onError, + #onDone: onDone, + #cancelOnError: cancelOnError, + }, + ), + returnValue: _FakeStreamSubscription_7>( + this, + Invocation.method( + #listen, + [onData], + { + #onError: onError, + #onDone: onDone, + #cancelOnError: cancelOnError, + }, + ), + ), + returnValueForMissingStub: _FakeStreamSubscription_7>( + this, + Invocation.method( + #listen, + [onData], + { + #onError: onError, + #onDone: onDone, + #cancelOnError: cancelOnError, + }, + ), + ), + ) as _i4.StreamSubscription>); + + @override + _i4.Stream> where(bool Function(List)? test) => (super.noSuchMethod( + Invocation.method( + #where, + [test], + ), + returnValue: _i4.Stream>.empty(), + returnValueForMissingStub: _i4.Stream>.empty(), + ) as _i4.Stream>); + + @override + _i4.Stream map(S Function(List)? convert) => (super.noSuchMethod( + Invocation.method( + #map, + [convert], + ), + returnValue: _i4.Stream.empty(), + returnValueForMissingStub: _i4.Stream.empty(), + ) as _i4.Stream); + + @override + _i4.Stream asyncMap(_i4.FutureOr Function(List)? convert) => (super.noSuchMethod( + Invocation.method( + #asyncMap, + [convert], + ), + returnValue: _i4.Stream.empty(), + returnValueForMissingStub: _i4.Stream.empty(), + ) as _i4.Stream); + + @override + _i4.Stream asyncExpand(_i4.Stream? Function(List)? convert) => (super.noSuchMethod( + Invocation.method( + #asyncExpand, + [convert], + ), + returnValue: _i4.Stream.empty(), + returnValueForMissingStub: _i4.Stream.empty(), + ) as _i4.Stream); + + @override + _i4.Stream> handleError( + Function? onError, { + bool Function(dynamic)? test, + }) => + (super.noSuchMethod( + Invocation.method( + #handleError, + [onError], + {#test: test}, + ), + returnValue: _i4.Stream>.empty(), + returnValueForMissingStub: _i4.Stream>.empty(), + ) as _i4.Stream>); + + @override + _i4.Stream expand(Iterable Function(List)? convert) => (super.noSuchMethod( + Invocation.method( + #expand, + [convert], + ), + returnValue: _i4.Stream.empty(), + returnValueForMissingStub: _i4.Stream.empty(), + ) as _i4.Stream); + + @override + _i4.Future pipe(_i4.StreamConsumer>? streamConsumer) => (super.noSuchMethod( + Invocation.method( + #pipe, + [streamConsumer], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Stream transform(_i4.StreamTransformer, S>? streamTransformer) => (super.noSuchMethod( + Invocation.method( + #transform, + [streamTransformer], + ), + returnValue: _i4.Stream.empty(), + returnValueForMissingStub: _i4.Stream.empty(), + ) as _i4.Stream); + + @override + _i4.Future> reduce( + List Function( + List, + List, + )? combine) => + (super.noSuchMethod( + Invocation.method( + #reduce, + [combine], + ), + returnValue: _i4.Future>.value([]), + returnValueForMissingStub: _i4.Future>.value([]), + ) as _i4.Future>); + + @override + _i4.Future fold( + S? initialValue, + S Function( + S, + List, + )? combine, + ) => + (super.noSuchMethod( + Invocation.method( + #fold, + [ + initialValue, + combine, + ], + ), + returnValue: _i5.ifNotNull( + _i5.dummyValueOrNull( + this, + Invocation.method( + #fold, + [ + initialValue, + combine, + ], + ), + ), + (S v) => _i4.Future.value(v), + ) ?? + _FakeFuture_8( + this, + Invocation.method( + #fold, + [ + initialValue, + combine, + ], + ), + ), + returnValueForMissingStub: _i5.ifNotNull( + _i5.dummyValueOrNull( + this, + Invocation.method( + #fold, + [ + initialValue, + combine, + ], + ), + ), + (S v) => _i4.Future.value(v), + ) ?? + _FakeFuture_8( + this, + Invocation.method( + #fold, + [ + initialValue, + combine, + ], + ), + ), + ) as _i4.Future); + + @override + _i4.Future join([String? separator = r'']) => (super.noSuchMethod( + Invocation.method( + #join, + [separator], + ), + returnValue: _i4.Future.value(_i5.dummyValue( + this, + Invocation.method( + #join, + [separator], + ), + )), + returnValueForMissingStub: _i4.Future.value(_i5.dummyValue( + this, + Invocation.method( + #join, + [separator], + ), + )), + ) as _i4.Future); + + @override + _i4.Future contains(Object? needle) => (super.noSuchMethod( + Invocation.method( + #contains, + [needle], + ), + returnValue: _i4.Future.value(false), + returnValueForMissingStub: _i4.Future.value(false), + ) as _i4.Future); + + @override + _i4.Future forEach(void Function(List)? action) => (super.noSuchMethod( + Invocation.method( + #forEach, + [action], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future every(bool Function(List)? test) => (super.noSuchMethod( + Invocation.method( + #every, + [test], + ), + returnValue: _i4.Future.value(false), + returnValueForMissingStub: _i4.Future.value(false), + ) as _i4.Future); + + @override + _i4.Future any(bool Function(List)? test) => (super.noSuchMethod( + Invocation.method( + #any, + [test], + ), + returnValue: _i4.Future.value(false), + returnValueForMissingStub: _i4.Future.value(false), + ) as _i4.Future); + + @override + _i4.Stream cast() => (super.noSuchMethod( + Invocation.method( + #cast, + [], + ), + returnValue: _i4.Stream.empty(), + returnValueForMissingStub: _i4.Stream.empty(), + ) as _i4.Stream); + + @override + _i4.Future>> toList() => (super.noSuchMethod( + Invocation.method( + #toList, + [], + ), + returnValue: _i4.Future>>.value(>[]), + returnValueForMissingStub: _i4.Future>>.value(>[]), + ) as _i4.Future>>); + + @override + _i4.Future>> toSet() => (super.noSuchMethod( + Invocation.method( + #toSet, + [], + ), + returnValue: _i4.Future>>.value(>{}), + returnValueForMissingStub: _i4.Future>>.value(>{}), + ) as _i4.Future>>); + + @override + _i4.Future drain([E? futureValue]) => (super.noSuchMethod( + Invocation.method( + #drain, + [futureValue], + ), + returnValue: _i5.ifNotNull( + _i5.dummyValueOrNull( + this, + Invocation.method( + #drain, + [futureValue], + ), + ), + (E v) => _i4.Future.value(v), + ) ?? + _FakeFuture_8( + this, + Invocation.method( + #drain, + [futureValue], + ), + ), + returnValueForMissingStub: _i5.ifNotNull( + _i5.dummyValueOrNull( + this, + Invocation.method( + #drain, + [futureValue], + ), + ), + (E v) => _i4.Future.value(v), + ) ?? + _FakeFuture_8( + this, + Invocation.method( + #drain, + [futureValue], + ), + ), + ) as _i4.Future); + + @override + _i4.Stream> take(int? count) => (super.noSuchMethod( + Invocation.method( + #take, + [count], + ), + returnValue: _i4.Stream>.empty(), + returnValueForMissingStub: _i4.Stream>.empty(), + ) as _i4.Stream>); + + @override + _i4.Stream> takeWhile(bool Function(List)? test) => (super.noSuchMethod( + Invocation.method( + #takeWhile, + [test], + ), + returnValue: _i4.Stream>.empty(), + returnValueForMissingStub: _i4.Stream>.empty(), + ) as _i4.Stream>); + + @override + _i4.Stream> skip(int? count) => (super.noSuchMethod( + Invocation.method( + #skip, + [count], + ), + returnValue: _i4.Stream>.empty(), + returnValueForMissingStub: _i4.Stream>.empty(), + ) as _i4.Stream>); + + @override + _i4.Stream> skipWhile(bool Function(List)? test) => (super.noSuchMethod( + Invocation.method( + #skipWhile, + [test], + ), + returnValue: _i4.Stream>.empty(), + returnValueForMissingStub: _i4.Stream>.empty(), + ) as _i4.Stream>); + + @override + _i4.Stream> distinct( + [bool Function( + List, + List, + )? equals]) => + (super.noSuchMethod( + Invocation.method( + #distinct, + [equals], + ), + returnValue: _i4.Stream>.empty(), + returnValueForMissingStub: _i4.Stream>.empty(), + ) as _i4.Stream>); + + @override + _i4.Future> firstWhere( + bool Function(List)? test, { + List Function()? orElse, + }) => + (super.noSuchMethod( + Invocation.method( + #firstWhere, + [test], + {#orElse: orElse}, + ), + returnValue: _i4.Future>.value([]), + returnValueForMissingStub: _i4.Future>.value([]), + ) as _i4.Future>); + + @override + _i4.Future> lastWhere( + bool Function(List)? test, { + List Function()? orElse, + }) => + (super.noSuchMethod( + Invocation.method( + #lastWhere, + [test], + {#orElse: orElse}, + ), + returnValue: _i4.Future>.value([]), + returnValueForMissingStub: _i4.Future>.value([]), + ) as _i4.Future>); + + @override + _i4.Future> singleWhere( + bool Function(List)? test, { + List Function()? orElse, + }) => + (super.noSuchMethod( + Invocation.method( + #singleWhere, + [test], + {#orElse: orElse}, + ), + returnValue: _i4.Future>.value([]), + returnValueForMissingStub: _i4.Future>.value([]), + ) as _i4.Future>); + + @override + _i4.Future> elementAt(int? index) => (super.noSuchMethod( + Invocation.method( + #elementAt, + [index], + ), + returnValue: _i4.Future>.value([]), + returnValueForMissingStub: _i4.Future>.value([]), + ) as _i4.Future>); + + @override + _i4.Stream> timeout( + Duration? timeLimit, { + void Function(_i4.EventSink>)? onTimeout, + }) => + (super.noSuchMethod( + Invocation.method( + #timeout, + [timeLimit], + {#onTimeout: onTimeout}, + ), + returnValue: _i4.Stream>.empty(), + returnValueForMissingStub: _i4.Stream>.empty(), + ) as _i4.Stream>); +} + +/// A class which mocks [HttpHeaders]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockHttpHeaders extends _i1.Mock implements _i2.HttpHeaders { + @override + set date(DateTime? _date) => super.noSuchMethod( + Invocation.setter( + #date, + _date, + ), + returnValueForMissingStub: null, + ); + + @override + set expires(DateTime? _expires) => super.noSuchMethod( + Invocation.setter( + #expires, + _expires, + ), + returnValueForMissingStub: null, + ); + + @override + set ifModifiedSince(DateTime? _ifModifiedSince) => super.noSuchMethod( + Invocation.setter( + #ifModifiedSince, + _ifModifiedSince, + ), + returnValueForMissingStub: null, + ); + + @override + set host(String? _host) => super.noSuchMethod( + Invocation.setter( + #host, + _host, + ), + returnValueForMissingStub: null, + ); + + @override + set port(int? _port) => super.noSuchMethod( + Invocation.setter( + #port, + _port, + ), + returnValueForMissingStub: null, + ); + + @override + set contentType(_i2.ContentType? _contentType) => super.noSuchMethod( + Invocation.setter( + #contentType, + _contentType, + ), + returnValueForMissingStub: null, + ); + + @override + int get contentLength => (super.noSuchMethod( + Invocation.getter(#contentLength), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + set contentLength(int? _contentLength) => super.noSuchMethod( + Invocation.setter( + #contentLength, + _contentLength, + ), + returnValueForMissingStub: null, + ); + + @override + bool get persistentConnection => (super.noSuchMethod( + Invocation.getter(#persistentConnection), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + set persistentConnection(bool? _persistentConnection) => super.noSuchMethod( + Invocation.setter( + #persistentConnection, + _persistentConnection, + ), + returnValueForMissingStub: null, + ); + + @override + bool get chunkedTransferEncoding => (super.noSuchMethod( + Invocation.getter(#chunkedTransferEncoding), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + set chunkedTransferEncoding(bool? _chunkedTransferEncoding) => super.noSuchMethod( + Invocation.setter( + #chunkedTransferEncoding, + _chunkedTransferEncoding, + ), + returnValueForMissingStub: null, + ); + + @override + List? operator [](String? name) => (super.noSuchMethod( + Invocation.method( + #[], + [name], + ), + returnValueForMissingStub: null, + ) as List?); + + @override + String? value(String? name) => (super.noSuchMethod( + Invocation.method( + #value, + [name], + ), + returnValueForMissingStub: null, + ) as String?); + + @override + void add( + String? name, + Object? value, { + bool? preserveHeaderCase = false, + }) => + super.noSuchMethod( + Invocation.method( + #add, + [ + name, + value, + ], + {#preserveHeaderCase: preserveHeaderCase}, + ), + returnValueForMissingStub: null, + ); + + @override + void set( + String? name, + Object? value, { + bool? preserveHeaderCase = false, + }) => + super.noSuchMethod( + Invocation.method( + #set, + [ + name, + value, + ], + {#preserveHeaderCase: preserveHeaderCase}, + ), + returnValueForMissingStub: null, + ); + + @override + void remove( + String? name, + Object? value, + ) => + super.noSuchMethod( + Invocation.method( + #remove, + [ + name, + value, + ], + ), + returnValueForMissingStub: null, + ); + + @override + void removeAll(String? name) => super.noSuchMethod( + Invocation.method( + #removeAll, + [name], + ), + returnValueForMissingStub: null, + ); + + @override + void forEach( + void Function( + String, + List, + )? action) => + super.noSuchMethod( + Invocation.method( + #forEach, + [action], + ), + returnValueForMissingStub: null, + ); + + @override + void noFolding(String? name) => super.noSuchMethod( + Invocation.method( + #noFolding, + [name], + ), + returnValueForMissingStub: null, + ); + + @override + void clear() => super.noSuchMethod( + Invocation.method( + #clear, + [], + ), + returnValueForMissingStub: null, + ); +} diff --git a/packages/dynamite/dynamite_end_to_end_test/test/parameters_test.dart b/packages/dynamite/dynamite_end_to_end_test/test/parameters_test.dart new file mode 100644 index 00000000000..8500e2cf72d --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/test/parameters_test.dart @@ -0,0 +1,124 @@ +// ignore_for_file: discarded_futures + +import 'dart:convert'; + +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/json_object.dart'; +import 'package:dynamite_end_to_end_test/parameters.openapi.dart'; +import 'package:dynamite_runtime/models.dart'; +import 'package:mockito/mockito.dart'; +import 'package:test/test.dart'; +import 'package:universal_io/io.dart'; + +import 'http_client_mock.mocks.dart'; + +late MockHttpClient mockHttpClient; + +class MockHttpOverrides extends HttpOverrides { + @override + HttpClient createHttpClient(final SecurityContext? context) => mockHttpClient; +} + +void main() { + late Client client; + late MockHttpHeaders headers; + late MockHttpClientResponse response; + late MockHttpClientRequest request; + + setUp(() { + mockHttpClient = MockHttpClient(); + HttpOverrides.global = MockHttpOverrides(); + + when(mockHttpClient.openUrl(any, any)).thenAnswer((final invocation) { + headers = MockHttpHeaders(); + + response = MockHttpClientResponse(); + when(response.headers).thenReturn(headers); + when(response.transform(any)).thenAnswer((final _) => Stream.value('{}')); + when(response.statusCode).thenReturn(200); + + request = MockHttpClientRequest(); + when(request.headers).thenReturn(headers); + when(request.close()).thenAnswer((final _) async => response); + return Future.value(request); + }); + + client = Client(Uri.parse('example.com')); + }); + + group(r'$get', () { + test('no parameters', () async { + await client.$get(); + final captured = verify(headers.add(captureAny, captureAny)).captured; + expect(captured, equals(['Accept', 'application/json'])); + }); + + test('with contentString', () async { + final contentString = ContentString>( + (final b) => b..content = BuiltMap({'key': JsonObject('value')}), + ); + + final queryComponent = Uri.encodeQueryComponent(json.encode({'key': 'value'})); + + await client.$get(contentString: contentString); + final captured = verify(mockHttpClient.openUrl(captureAny, captureAny)).captured; + expect( + captured, + equals([ + 'get', + Uri.parse('example.com/?content-string=$queryComponent'), + ]), + ); + }); + + test('with contentParameter', () async { + final contentParameter = ContentString>( + (final b) => b..content = BuiltMap({'key': JsonObject('value')}), + ); + + final queryComponent = Uri.encodeQueryComponent(json.encode({'key': 'value'})); + + await client.$get(contentParameter: contentParameter); + final captured = verify(mockHttpClient.openUrl(captureAny, captureAny)).captured; + expect( + captured, + equals([ + 'get', + Uri.parse('example.com/?content-parameter=$queryComponent'), + ]), + ); + }); + + test('with multiple query parameters', () async { + final contentString = ContentString>( + (final b) => b..content = BuiltMap({'key': JsonObject('value')}), + ); + + final queryComponent = Uri.encodeQueryComponent(json.encode({'key': 'value'})); + + await client.$get(contentString: contentString, contentParameter: contentString); + final captured = verify(mockHttpClient.openUrl(captureAny, captureAny)).captured; + expect( + captured, + equals([ + 'get', + Uri.parse('example.com/?content-string=$queryComponent&content-parameter=$queryComponent'), + ]), + ); + }); + }); + + group('getPathParameter', () { + test('empty path', () async { + await client.getPathParameter(pathParameter: 'parameter'); + final captured = verify(mockHttpClient.openUrl(captureAny, captureAny)).captured; + expect( + captured, + equals([ + 'get', + Uri.parse('example.com/parameter'), + ]), + ); + }); + }); +} diff --git a/tool/find-dart-io-usage.sh b/tool/find-dart-io-usage.sh index 009d5cca834..5e9a48dc4f4 100755 --- a/tool/find-dart-io-usage.sh +++ b/tool/find-dart-io-usage.sh @@ -2,7 +2,7 @@ set -euxo pipefail cd "$(dirname "$0")/.." -dart_io_usage=("$(grep -r packages --include "*\.dart" -e "dart:io" -l | grep -v "/\.dart_tool/" | grep -v "/bin/" | grep -v "/test_driver/" || true)") +dart_io_usage=("$(grep -r packages --include "*\.dart" --exclude "*\.mocks\.dart" -e "dart:io" -l | grep -v "/\.dart_tool/" | grep -v "/bin/" | grep -v "/test_driver/" || true)") if [[ -n "${dart_io_usage[*]}" ]]; then printf "%s\n" "${dart_io_usage[@]}"