Skip to content

Commit 615ef3d

Browse files
authored
feat: add integrated tests (#19)
1 parent 859c7f6 commit 615ef3d

File tree

10 files changed

+680
-7
lines changed

10 files changed

+680
-7
lines changed

.github/workflows/main.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,22 @@ jobs:
1818

1919
build:
2020
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1
21+
22+
integration_tests:
23+
runs-on: ubuntu-latest
24+
defaults:
25+
run:
26+
working-directory: "example/"
27+
28+
steps:
29+
- name: 📚 Git Checkout
30+
uses: actions/checkout@v3
31+
32+
- name: 🎯 Setup Dart
33+
uses: dart-lang/setup-dart@v1
34+
35+
- name: 📦 Install Dependencies
36+
run: dart pub get
37+
38+
- name: 🧪 Run Tests
39+
run: dart test -t integration

example/dart_test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tags:
2+
integration:

example/lib/src/commands/some_commmand.dart

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class SomeCommand extends Command<int> {
1212
abbr: 'd',
1313
help: 'A discrete option with "allowed" values (mandatory)',
1414
allowed: ['foo', 'bar', 'faa'],
15+
aliases: [
16+
'allowed',
17+
'defined-values',
18+
],
1519
allowedHelp: {
1620
'foo': 'foo help',
1721
'bar': 'bar help',
@@ -20,18 +24,29 @@ class SomeCommand extends Command<int> {
2024
mandatory: true,
2125
)
2226
..addOption(
23-
'continuous',
24-
abbr: 'c',
27+
'hidden',
28+
hide: true,
29+
help: 'A hidden option',
30+
)
31+
..addOption(
32+
'continuous', // intentionally, this one does not have an abbr
2533
help: 'A continuous option: any value is allowed',
2634
)
2735
..addMultiOption(
2836
'multi-d',
2937
abbr: 'm',
30-
allowed: ['fii', 'bar', 'fee'],
38+
allowed: [
39+
'fii',
40+
'bar',
41+
'fee',
42+
'i have space', // arg parser wont accept space on "allowed" values,
43+
// therefore this should never appear on completions
44+
],
3145
allowedHelp: {
3246
'fii': 'fii help',
3347
'bar': 'bar help',
3448
'fee': 'fee help',
49+
'i have space': 'an allowed option with space on it',
3550
},
3651
help: 'An discrete option that can be passed multiple times ',
3752
)
@@ -66,6 +81,12 @@ class SomeCommand extends Command<int> {
6681
@override
6782
String get name => 'some_command';
6883

84+
@override
85+
List<String> get aliases => [
86+
'disguised:some_commmand',
87+
'melon',
88+
];
89+
6990
@override
7091
Future<int> run() async {
7192
for (final option in argResults!.options) {

example/lib/src/commands/some_other_commmand.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ class SomeOtherCommand extends Command<int> {
1919
/// A command under [SomeOtherCommand] that does not receive options and read
2020
/// the "rest" field from arg results
2121
class _SomeSubCommand extends Command<int> {
22-
_SomeSubCommand(this._logger);
22+
_SomeSubCommand(this._logger) {
23+
argParser.addFlag(
24+
'flag',
25+
help: 'a flag just to show we are in the subcommand',
26+
);
27+
}
2328

2429
final Logger _logger;
2530

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

37+
@override
38+
List<String> get aliases => ['subcommand_alias'];
39+
3240
@override
3341
Future<int> run() async {
3442
_logger.info(description);

example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dependencies:
1111
cli_completion:
1212
path: ../
1313
mason_logger: ^0.2.0
14+
meta: ^1.8.0
1415

1516
dev_dependencies:
1617
mocktail: ^0.3.0

0 commit comments

Comments
 (0)