Skip to content

Commit

Permalink
⚡️ Mark DioMixin's todo and add tests (#2066)
Browse files Browse the repository at this point in the history
`DioMixin` was never a real mixin before. Marking it to use `mixin
class` once we use `>=3.0.0` as the SDK constraint.

### 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)
- [x] I have added the required tests to prove the fix/feature I'm
adding
- [x] 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

### Additional context and info (if any)

The following exception will be raised if we roll the lower bound of the
package to ^3.0.0:
`The class 'DioMixin' can't be used as a mixin because it's neither a
mixin class nor a mixin.`
  • Loading branch information
AlexV525 authored Dec 14, 2023
1 parent c400435 commit 4b1f1ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions dio/lib/src/dio_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import 'progress_stream/io_progress_stream.dart'

part 'interceptor.dart';

// TODO(EVERYONE): Use `mixin class` when the lower bound of SDK is raised to 3.0.0.
abstract class DioMixin implements Dio {
/// The base request config for the instance.
@override
Expand Down
7 changes: 7 additions & 0 deletions dio/test/dio_mixin_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import 'package:dio/dio.dart';
import 'package:test/test.dart';

void main() {
test('not thrown for implements', () {
expect(_TestDioMixin().interceptors, isA<Interceptors>());
expect(_TestDioMixinExtends().interceptors, isA<Interceptors>());
});

test('assureResponse', () {
final requestOptions = RequestOptions(path: '');
final untypedResponse = Response<dynamic>(
Expand All @@ -26,3 +31,5 @@ void main() {
}

class _TestDioMixin with DioMixin implements Dio {}

class _TestDioMixinExtends extends DioMixin implements Dio {}

0 comments on commit 4b1f1ec

Please sign in to comment.