Add Github Actions and dependabot, Add mocktaiol instead of Mockito for testing, bump minimum flutter version to 3.0.0

This commit is contained in:
Thomas Klein Langenhorst 2023-04-01 19:36:44 +02:00
parent 500ed1d080
commit ea1f4d76eb
5 changed files with 62 additions and 22 deletions

10
.github/dependabot.yaml vendored Normal file
View file

@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "pub"
directory: "/"
schedule:
interval: "daily"

32
.github/workflows/flutter.yml vendored Normal file
View file

@ -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

View file

@ -92,7 +92,7 @@ abstract class DataInterface {
} }
/// A [DataInterface] mixin that can be combined with fake or mock objects, /// 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 /// It passes the [DataInterface.verify] check even though it isn't
/// using `extends`. /// using `extends`.

View file

@ -6,16 +6,17 @@ repository: https://github.com/Iconica-Development/flutter_data_interface
environment: environment:
sdk: '>=2.18.0 <3.0.0' sdk: '>=2.18.0 <3.0.0'
flutter: ">=1.17.0" flutter: ">=3.0.0"
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
mockito: any meta: ^1.8.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.0 flutter_lints: ^2.0.0
mocktail: ^0.3.0
flutter: flutter:

View file

@ -4,7 +4,7 @@
import 'package:flutter_data_interface/flutter_data_interface.dart'; import 'package:flutter_data_interface/flutter_data_interface.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart'; import 'package:mocktail/mocktail.dart';
class SamplePluginPlatform extends DataInterface { class SamplePluginPlatform extends DataInterface {
SamplePluginPlatform() : super(token: _token); SamplePluginPlatform() : super(token: _token);
@ -18,20 +18,19 @@ class SamplePluginPlatform extends DataInterface {
} }
} }
class ImplementsSamplePluginPlatform extends Mock class MockSamplePluginPlatform extends Mock implements SamplePluginPlatform {}
implements SamplePluginPlatform {}
class ImplementsSamplePluginPlatformUsingNoSuchMethod class MockSamplePluginPlatformUsingNoSuchMethod
implements SamplePluginPlatform { implements SamplePluginPlatform {
@override @override
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
} }
class ImplementsSamplePluginPlatformUsingMockPlatformInterfaceMixin extends Mock class MockSamplePluginPlatformUsingMockPlatformInterfaceMixin extends Mock
with MockDataInterfaceMixin with MockDataInterfaceMixin
implements SamplePluginPlatform {} implements SamplePluginPlatform {}
class ImplementsSamplePluginPlatformUsingFakePlatformInterfaceMixin extends Fake class MockSamplePluginPlatformUsingFakePlatformInterfaceMixin extends Fake
with MockDataInterfaceMixin with MockDataInterfaceMixin
implements SamplePluginPlatform {} implements SamplePluginPlatform {}
@ -62,11 +61,10 @@ class VerifyTokenPluginPlatform extends DataInterface {
} }
} }
class ImplementsVerifyTokenPluginPlatform extends Mock class MockVerifyTokenPluginPlatform extends Mock
implements VerifyTokenPluginPlatform {} implements VerifyTokenPluginPlatform {}
class ImplementsVerifyTokenPluginPlatformUsingMockPlatformInterfaceMixin class MockVerifyTokenPluginPlatformUsingMockPlatformInterfaceMixin extends Mock
extends Mock
with MockDataInterfaceMixin with MockDataInterfaceMixin
implements VerifyTokenPluginPlatform {} implements VerifyTokenPluginPlatform {}
@ -83,9 +81,9 @@ class ConstVerifyTokenPluginPlatform extends DataInterface {
} }
} }
class ImplementsConstVerifyTokenPluginPlatform extends DataInterface class MockConstVerifyTokenPluginPlatform extends DataInterface
implements ConstVerifyTokenPluginPlatform { implements ConstVerifyTokenPluginPlatform {
ImplementsConstVerifyTokenPluginPlatform() : super(token: const Object()); MockConstVerifyTokenPluginPlatform() : super(token: const Object());
} }
// Ensures that `PlatformInterface` has no instance methods. Adding an // Ensures that `PlatformInterface` has no instance methods. Adding an
@ -100,26 +98,26 @@ void main() {
group('`verify`', () { group('`verify`', () {
test('prevents implementation with `implements`', () { test('prevents implementation with `implements`', () {
expect(() { expect(() {
SamplePluginPlatform.instance = ImplementsSamplePluginPlatform(); SamplePluginPlatform.instance = MockSamplePluginPlatform();
}, throwsA(isA<AssertionError>())); }, throwsA(isA<AssertionError>()));
}); });
test('prevents implmentation with `implements` and `noSuchMethod`', () { test('prevents implmentation with `implements` and `noSuchMethod`', () {
expect(() { expect(() {
SamplePluginPlatform.instance = SamplePluginPlatform.instance =
ImplementsSamplePluginPlatformUsingNoSuchMethod(); MockSamplePluginPlatformUsingNoSuchMethod();
}, throwsA(isA<AssertionError>())); }, throwsA(isA<AssertionError>()));
}); });
test('allows mocking with `implements`', () { test('allows mocking with `implements`', () {
final SamplePluginPlatform mock = final SamplePluginPlatform mock =
ImplementsSamplePluginPlatformUsingMockPlatformInterfaceMixin(); MockSamplePluginPlatformUsingMockPlatformInterfaceMixin();
SamplePluginPlatform.instance = mock; SamplePluginPlatform.instance = mock;
}); });
test('allows faking with `implements`', () { test('allows faking with `implements`', () {
final SamplePluginPlatform fake = final SamplePluginPlatform fake =
ImplementsSamplePluginPlatformUsingFakePlatformInterfaceMixin(); MockSamplePluginPlatformUsingFakePlatformInterfaceMixin();
SamplePluginPlatform.instance = fake; SamplePluginPlatform.instance = fake;
}); });
@ -138,14 +136,13 @@ void main() {
group('`verifyToken`', () { group('`verifyToken`', () {
test('prevents implementation with `implements`', () { test('prevents implementation with `implements`', () {
expect(() { expect(() {
VerifyTokenPluginPlatform.instance = VerifyTokenPluginPlatform.instance = MockVerifyTokenPluginPlatform();
ImplementsVerifyTokenPluginPlatform();
}, throwsA(isA<AssertionError>())); }, throwsA(isA<AssertionError>()));
}); });
test('allows mocking with `implements`', () { test('allows mocking with `implements`', () {
final VerifyTokenPluginPlatform mock = final VerifyTokenPluginPlatform mock =
ImplementsVerifyTokenPluginPlatformUsingMockPlatformInterfaceMixin(); MockVerifyTokenPluginPlatformUsingMockPlatformInterfaceMixin();
VerifyTokenPluginPlatform.instance = mock; VerifyTokenPluginPlatform.instance = mock;
}); });
@ -155,7 +152,7 @@ void main() {
test('does not prevent `const Object()` token', () { test('does not prevent `const Object()` token', () {
ConstVerifyTokenPluginPlatform.instance = ConstVerifyTokenPluginPlatform.instance =
ImplementsConstVerifyTokenPluginPlatform(); MockConstVerifyTokenPluginPlatform();
}); });
}); });
} }