Skip to content

Commit

Permalink
feat: add integrated tests (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
renancaraujo committed Nov 22, 2022
1 parent 859c7f6 commit 615ef3d
Show file tree
Hide file tree
Showing 10 changed files with 680 additions and 7 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/main.yaml
Expand Up @@ -18,3 +18,22 @@ jobs:

build:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1

integration_tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: "example/"

steps:
- name: 馃摎 Git Checkout
uses: actions/checkout@v3

- name: 馃幆 Setup Dart
uses: dart-lang/setup-dart@v1

- name: 馃摝 Install Dependencies
run: dart pub get

- name: 馃И Run Tests
run: dart test -t integration
2 changes: 2 additions & 0 deletions example/dart_test.yaml
@@ -0,0 +1,2 @@
tags:
integration:
27 changes: 24 additions & 3 deletions example/lib/src/commands/some_commmand.dart
Expand Up @@ -12,6 +12,10 @@ class SomeCommand extends Command<int> {
abbr: 'd',
help: 'A discrete option with "allowed" values (mandatory)',
allowed: ['foo', 'bar', 'faa'],
aliases: [
'allowed',
'defined-values',
],
allowedHelp: {
'foo': 'foo help',
'bar': 'bar help',
Expand All @@ -20,18 +24,29 @@ class SomeCommand extends Command<int> {
mandatory: true,
)
..addOption(
'continuous',
abbr: 'c',
'hidden',
hide: true,
help: 'A hidden option',
)
..addOption(
'continuous', // intentionally, this one does not have an abbr
help: 'A continuous option: any value is allowed',
)
..addMultiOption(
'multi-d',
abbr: 'm',
allowed: ['fii', 'bar', 'fee'],
allowed: [
'fii',
'bar',
'fee',
'i have space', // arg parser wont accept space on "allowed" values,
// therefore this should never appear on completions
],
allowedHelp: {
'fii': 'fii help',
'bar': 'bar help',
'fee': 'fee help',
'i have space': 'an allowed option with space on it',
},
help: 'An discrete option that can be passed multiple times ',
)
Expand Down Expand Up @@ -66,6 +81,12 @@ class SomeCommand extends Command<int> {
@override
String get name => 'some_command';

@override
List<String> get aliases => [
'disguised:some_commmand',
'melon',
];

@override
Future<int> run() async {
for (final option in argResults!.options) {
Expand Down
10 changes: 9 additions & 1 deletion example/lib/src/commands/some_other_commmand.dart
Expand Up @@ -19,7 +19,12 @@ class SomeOtherCommand extends Command<int> {
/// A command under [SomeOtherCommand] that does not receive options and read
/// the "rest" field from arg results
class _SomeSubCommand extends Command<int> {
_SomeSubCommand(this._logger);
_SomeSubCommand(this._logger) {
argParser.addFlag(
'flag',
help: 'a flag just to show we are in the subcommand',
);
}

final Logger _logger;

Expand All @@ -29,6 +34,9 @@ class _SomeSubCommand extends Command<int> {
@override
String get name => 'subcommand';

@override
List<String> get aliases => ['subcommand_alias'];

@override
Future<int> run() async {
_logger.info(description);
Expand Down
1 change: 1 addition & 0 deletions example/pubspec.yaml
Expand Up @@ -11,6 +11,7 @@ dependencies:
cli_completion:
path: ../
mason_logger: ^0.2.0
meta: ^1.8.0

dev_dependencies:
mocktail: ^0.3.0
Expand Down

0 comments on commit 615ef3d

Please sign in to comment.