From ea1f4d76ebe2f51a537ab7c202e1f5e3707dfc4e Mon Sep 17 00:00:00 2001 From: Thomas Klein Langenhorst Date: Sat, 1 Apr 2023 19:36:44 +0200 Subject: [PATCH] Add Github Actions and dependabot, Add mocktaiol instead of Mockito for testing, bump minimum flutter version to 3.0.0 --- .github/dependabot.yaml | 10 ++++++++ .github/workflows/flutter.yml | 32 ++++++++++++++++++++++++ lib/flutter_data_interface.dart | 2 +- pubspec.yaml | 5 ++-- test/flutter_data_interface_test.dart | 35 ++++++++++++--------------- 5 files changed, 62 insertions(+), 22 deletions(-) create mode 100644 .github/dependabot.yaml create mode 100644 .github/workflows/flutter.yml diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..33826d0 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "pub" + directory: "/" + schedule: + interval: "daily" \ No newline at end of file diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml new file mode 100644 index 0000000..50bb90a --- /dev/null +++ b/.github/workflows/flutter.yml @@ -0,0 +1,32 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: + - master + - feature/* + - bugfix/* + - hotfix/* + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.gradle/wrapper + /opt/hostedtoolcache/flutter + key: ${{ runner.OS }}-flutter-install-cache + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + - name: Flutter pub get + run: flutter pub get + - name: Flutter format + run: flutter format -o none --set-exit-if-changed . + - name: Flutter analyze + run: flutter analyze diff --git a/lib/flutter_data_interface.dart b/lib/flutter_data_interface.dart index 3c42794..c518d10 100644 --- a/lib/flutter_data_interface.dart +++ b/lib/flutter_data_interface.dart @@ -92,7 +92,7 @@ abstract class DataInterface { } /// A [DataInterface] mixin that can be combined with fake or mock objects, -/// such as test's `Fake` or mockito's `Mock`. +/// such as test's `Fake` or mocktail's `Mock`. /// /// It passes the [DataInterface.verify] check even though it isn't /// using `extends`. diff --git a/pubspec.yaml b/pubspec.yaml index 58a58d2..6b9cd10 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,16 +6,17 @@ repository: https://github.com/Iconica-Development/flutter_data_interface environment: sdk: '>=2.18.0 <3.0.0' - flutter: ">=1.17.0" + flutter: ">=3.0.0" dependencies: flutter: sdk: flutter - mockito: any + meta: ^1.8.0 dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^2.0.0 + mocktail: ^0.3.0 flutter: diff --git a/test/flutter_data_interface_test.dart b/test/flutter_data_interface_test.dart index a6cfaa5..2638f1b 100644 --- a/test/flutter_data_interface_test.dart +++ b/test/flutter_data_interface_test.dart @@ -4,7 +4,7 @@ import 'package:flutter_data_interface/flutter_data_interface.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; +import 'package:mocktail/mocktail.dart'; class SamplePluginPlatform extends DataInterface { SamplePluginPlatform() : super(token: _token); @@ -18,20 +18,19 @@ class SamplePluginPlatform extends DataInterface { } } -class ImplementsSamplePluginPlatform extends Mock - implements SamplePluginPlatform {} +class MockSamplePluginPlatform extends Mock implements SamplePluginPlatform {} -class ImplementsSamplePluginPlatformUsingNoSuchMethod +class MockSamplePluginPlatformUsingNoSuchMethod implements SamplePluginPlatform { @override dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); } -class ImplementsSamplePluginPlatformUsingMockPlatformInterfaceMixin extends Mock +class MockSamplePluginPlatformUsingMockPlatformInterfaceMixin extends Mock with MockDataInterfaceMixin implements SamplePluginPlatform {} -class ImplementsSamplePluginPlatformUsingFakePlatformInterfaceMixin extends Fake +class MockSamplePluginPlatformUsingFakePlatformInterfaceMixin extends Fake with MockDataInterfaceMixin implements SamplePluginPlatform {} @@ -62,11 +61,10 @@ class VerifyTokenPluginPlatform extends DataInterface { } } -class ImplementsVerifyTokenPluginPlatform extends Mock +class MockVerifyTokenPluginPlatform extends Mock implements VerifyTokenPluginPlatform {} -class ImplementsVerifyTokenPluginPlatformUsingMockPlatformInterfaceMixin - extends Mock +class MockVerifyTokenPluginPlatformUsingMockPlatformInterfaceMixin extends Mock with MockDataInterfaceMixin implements VerifyTokenPluginPlatform {} @@ -83,9 +81,9 @@ class ConstVerifyTokenPluginPlatform extends DataInterface { } } -class ImplementsConstVerifyTokenPluginPlatform extends DataInterface +class MockConstVerifyTokenPluginPlatform extends DataInterface implements ConstVerifyTokenPluginPlatform { - ImplementsConstVerifyTokenPluginPlatform() : super(token: const Object()); + MockConstVerifyTokenPluginPlatform() : super(token: const Object()); } // Ensures that `PlatformInterface` has no instance methods. Adding an @@ -100,26 +98,26 @@ void main() { group('`verify`', () { test('prevents implementation with `implements`', () { expect(() { - SamplePluginPlatform.instance = ImplementsSamplePluginPlatform(); + SamplePluginPlatform.instance = MockSamplePluginPlatform(); }, throwsA(isA())); }); test('prevents implmentation with `implements` and `noSuchMethod`', () { expect(() { SamplePluginPlatform.instance = - ImplementsSamplePluginPlatformUsingNoSuchMethod(); + MockSamplePluginPlatformUsingNoSuchMethod(); }, throwsA(isA())); }); test('allows mocking with `implements`', () { final SamplePluginPlatform mock = - ImplementsSamplePluginPlatformUsingMockPlatformInterfaceMixin(); + MockSamplePluginPlatformUsingMockPlatformInterfaceMixin(); SamplePluginPlatform.instance = mock; }); test('allows faking with `implements`', () { final SamplePluginPlatform fake = - ImplementsSamplePluginPlatformUsingFakePlatformInterfaceMixin(); + MockSamplePluginPlatformUsingFakePlatformInterfaceMixin(); SamplePluginPlatform.instance = fake; }); @@ -138,14 +136,13 @@ void main() { group('`verifyToken`', () { test('prevents implementation with `implements`', () { expect(() { - VerifyTokenPluginPlatform.instance = - ImplementsVerifyTokenPluginPlatform(); + VerifyTokenPluginPlatform.instance = MockVerifyTokenPluginPlatform(); }, throwsA(isA())); }); test('allows mocking with `implements`', () { final VerifyTokenPluginPlatform mock = - ImplementsVerifyTokenPluginPlatformUsingMockPlatformInterfaceMixin(); + MockVerifyTokenPluginPlatformUsingMockPlatformInterfaceMixin(); VerifyTokenPluginPlatform.instance = mock; }); @@ -155,7 +152,7 @@ void main() { test('does not prevent `const Object()` token', () { ConstVerifyTokenPluginPlatform.instance = - ImplementsConstVerifyTokenPluginPlatform(); + MockConstVerifyTokenPluginPlatform(); }); }); }