diff --git a/test/functional_test.dart b/test/functional_test.dart index 268accc..e35fc82 100644 --- a/test/functional_test.dart +++ b/test/functional_test.dart @@ -7,6 +7,8 @@ import 'package:path/path.dart' as path; import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:test/test.dart'; +import 'subcommands_usage.expect.dart'; + void main() { late Directory temp; final out = BufferChannel(); @@ -232,12 +234,33 @@ I love my dog. expect(err.buffer.toString().trim(), 'The next version must be higher than the current one.'); }); - test('version part must be specified', () async { + test('incorrect usage', () async { final code = await run(['bump']); expect(code, 64); expect(err.buffer.toString().trim().split('\n')[0], 'Usage: cider bump [arguments]'); }); + test('help usage', () async { + final code = await run(['bump', '--help']); + expect(code, 0); + expect(err.buffer.toString(), isEmpty); + expectSubcommandsUsage(out.buffer.toString(), command: 'bump'); + }); + }); + }); + + group('Log', () { + test('incorrect usage', () async { + final code = await run(['log']); + expect(code, 64); + expect(err.buffer.toString().trim().split('\n')[0], + 'Usage: cider log [arguments]'); + }); + test('help usage', () async { + final code = await run(['log', '--help']); + expect(code, 0); + expect(err.buffer.toString(), isEmpty); + expectSubcommandsUsage(out.buffer.toString(), command: 'log'); }); }); diff --git a/test/subcommands_usage.expect.dart b/test/subcommands_usage.expect.dart new file mode 100644 index 0000000..3e0cdd1 --- /dev/null +++ b/test/subcommands_usage.expect.dart @@ -0,0 +1,10 @@ +import 'package:test/test.dart'; + +void expectSubcommandsUsage(String output, {String? command}) { + if (command != null) { + expect(output, contains('Usage: cider $command [arguments]')); + } + expect(output, contains('-h, --help Print this usage information.')); + expect(output, contains('Available subcommands:')); + expect(output, contains('Run "cider help" to see global options.')); +}