Skip to content

Commit

Permalink
test: bump and log usage output test
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-kolja committed Jan 30, 2024
1 parent d1eb32c commit 94fd222
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
25 changes: 24 additions & 1 deletion test/functional_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 <subcommand> [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 <subcommand> [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');
});
});

Expand Down
10 changes: 10 additions & 0 deletions test/subcommands_usage.expect.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:test/test.dart';

void expectSubcommandsUsage(String output, {String? command}) {
if (command != null) {
expect(output, contains('Usage: cider $command <subcommand> [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.'));
}

0 comments on commit 94fd222

Please sign in to comment.