mirror of
https://github.com/Iconica-Development/flutter_data_interface.git
synced 2025-05-18 18:33:45 +02:00
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:
parent
500ed1d080
commit
ea1f4d76eb
5 changed files with 62 additions and 22 deletions
10
.github/dependabot.yaml
vendored
Normal file
10
.github/dependabot.yaml
vendored
Normal 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
32
.github/workflows/flutter.yml
vendored
Normal 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
|
|
@ -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`.
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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<AssertionError>()));
|
||||
});
|
||||
|
||||
test('prevents implmentation with `implements` and `noSuchMethod`', () {
|
||||
expect(() {
|
||||
SamplePluginPlatform.instance =
|
||||
ImplementsSamplePluginPlatformUsingNoSuchMethod();
|
||||
MockSamplePluginPlatformUsingNoSuchMethod();
|
||||
}, throwsA(isA<AssertionError>()));
|
||||
});
|
||||
|
||||
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<AssertionError>()));
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue