Skip to content

Commit

Permalink
Fix mocks not compatible with Dart 2.15 causing test failures (cfug#1847
Browse files Browse the repository at this point in the history
)

* revert mockito version and mocks

This PR just reverts some recent changes to mocks which are not
supported on Dart 2.15 and cause some CI tests to fail.
The test failures have gone unnoticed due to all the noise around
httpbin not working.

When merging this change to the 6.0.0 branch, we need to make sure to
skip this.

### New Pull Request Checklist

- [x] I have read the
[Documentation](https://pub.dev/documentation/dio/latest/)
- [x] I have searched for a similar pull request in the
[project](https://github.com/cfug/dio/pulls) and found none
- [x] I have updated this branch with the latest `main` branch to avoid
conflicts (via merge from master or rebase)
- [ ] I have added the required tests to prove the fix/feature I'm
adding
- [ ] I have updated the documentation (if necessary)
- [x] I have run the tests without failures
- [ ] I have updated the `CHANGELOG.md` in the corresponding package
  • Loading branch information
kuhnroyal authored Jun 2, 2023
1 parent 073efb4 commit 1883bab
Show file tree
Hide file tree
Showing 4 changed files with 517 additions and 1,649 deletions.
2 changes: 1 addition & 1 deletion dio/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ dev_dependencies:
test: ^1.5.1
coverage: ^1.0.3
crypto: ^3.0.2
mockito: ^5.3.0
mockito: ^5.2.0
build_runner: any
2 changes: 1 addition & 1 deletion dio/test/cancel_token_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void main() {
);
}

await Future.delayed(const Duration(milliseconds: 5));
await Future.delayed(const Duration(milliseconds: 50));
token.cancel(reason);

expect(requests, hasLength(2));
Expand Down
15 changes: 9 additions & 6 deletions dio/test/mock/http_mock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import 'http_mock.mocks.dart';

final httpClientMock = MockHttpClient();

@GenerateNiceMocks([
MockSpec<HttpClient>(),
MockSpec<HttpClientRequest>(),
MockSpec<HttpClientResponse>(),
MockSpec<HttpHeaders>(),
])
@GenerateMocks(
[],
customMocks: [
MockSpec<HttpClient>(),
MockSpec<HttpClientRequest>(),
MockSpec<HttpClientResponse>(),
MockSpec<HttpHeaders>(),
],
)
class MockHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext? context) {
Expand Down
Loading

0 comments on commit 1883bab

Please sign in to comment.