Service Package
A brick to create your service package including your methods, models, tests, and more!
This brick makes use of the MasonGenerator and wraps 2 other bricks (service and model) to create a fully fledged package with tests already pre generated!
How to use š
mason make service_package --package_name "authentication repository" --package_description "Authentication Package"
Variables āØ
Variable | Description | Default | Type |
---|---|---|---|
package_name | The name of the package | data repository | string |
package_description | The package description | A default package description | string |
Bricks Used š§±
Brick | Version |
---|---|
service | 0.0.3 |
model | 0.3.5 |
Outputs š¦
--package_name "authentication repository" --package_description "Authentication Package"
āāā authentication_repository
ā āāā lib
ā ā āāā src
ā ā ā āāā models
ā ā ā ā āāā yourModelOne.dart
ā ā ā ā āāā yourModelTwo.dart
ā ā ā ā āāā etc
ā ā ā āāā authentication_repository.dart
ā ā ā āāā iauthentication_repository.dart
ā ā āāā authentication_repository.dart
ā āāā test
ā ā āāā src
ā ā āāā authentication_repository_test.dart
ā āāā .gitignore
ā āāā analysis_options.yaml
ā āāā pubspec.yaml
ā āāā README.md
āāā ...
Service File
part 'iauthentication_repository.dart';
/// {@template authentication_repository}
/// AuthenticationRepository description
/// {@endtemplate}
class AuthenticationRepository implements IAuthenticationRepository {
/// {@macro authentication_repository}
const AuthenticationRepository();
@override
FutureOr<String> authenticateUser() async {
//TODO: Add Logic
return Future.value();
}
@override
FutureOr<String> logOut() async {
//TODO: Add Logic
return Future.value();
}
}
Tests File
import 'package:data_repository/data_repository.dart';
import 'package:test/test.dart';
void main() {
group('AuthenticationRepository', () {
late AuthenticationRepository authenticationRepository;
setUp(() {
authenticationRepository = const AuthenticationRepository();
});
test('can be instantiated', () {
expect(const AuthenticationRepository(), isNotNull);
});
group('authenticateUser', () {
test('executes happy flow', () async {
final someValue = authenticationRepository.authenticateUser();
//expect(someValue, equals(someValue));
});
test('executes edge flow', () async {
final someValue = authenticationRepository.authenticateUser();
//expect(someValue, equals(someValue));
});
});
group('logOut', () {
test('executes happy flow', () async {
final someValue = authenticationRepository.logOut();
//expect(someValue, equals(someValue));
});
test('executes edge flow', () async {
final someValue = authenticationRepository.logOut();
//expect(someValue, equals(someValue));
});
});
});
}
Roadmap
- Add equatable as package if a model uses it
- Wait for other bricks to be updated