|
| 1 | +import 'package:flutter_gen_core/utils/version.dart'; |
| 2 | +import 'package:test/test.dart'; |
| 3 | +import 'package:test_process/test_process.dart'; |
| 4 | + |
| 5 | +void main() { |
| 6 | + test('Execute fluttergen', () async { |
| 7 | + final process = |
| 8 | + await TestProcess.start('dart', ['bin/flutter_gen_command.dart']); |
| 9 | + expect(await process.stdout.next, |
| 10 | + equals('$flutterGenVersion Loading ... command/pubspec.yaml')); |
| 11 | + await process.shouldExit(0); |
| 12 | + }); |
| 13 | + |
| 14 | + test('Execute fluttergen --config pubspec.yaml', () async { |
| 15 | + var process = await TestProcess.start( |
| 16 | + 'dart', ['bin/flutter_gen_command.dart', '--config', 'pubspec.yaml']); |
| 17 | + expect(await process.stdout.next, |
| 18 | + equals('$flutterGenVersion Loading ... command/pubspec.yaml')); |
| 19 | + await process.shouldExit(0); |
| 20 | + }); |
| 21 | + |
| 22 | + test('Execute fluttergen --help', () async { |
| 23 | + var process = await TestProcess.start( |
| 24 | + 'dart', ['bin/flutter_gen_command.dart', '--help']); |
| 25 | + expect(await process.stdout.next, |
| 26 | + equals('-c, --config Set the path of pubspec.yaml.')); |
| 27 | + final line = await process.stdout.next; |
| 28 | + expect(line.trim(), equals('(defaults to "pubspec.yaml")')); |
| 29 | + await process.shouldExit(0); |
| 30 | + }); |
| 31 | + |
| 32 | + test('Execute fluttergen --version', () async { |
| 33 | + var process = await TestProcess.start( |
| 34 | + 'dart', ['bin/flutter_gen_command.dart', '--version']); |
| 35 | + expect(await process.stdout.next, equals(flutterGenVersion)); |
| 36 | + await process.shouldExit(0); |
| 37 | + }); |
| 38 | + |
| 39 | + test('Execute wrong argments with fluttergen --wrong', () async { |
| 40 | + var process = await TestProcess.start( |
| 41 | + 'dart', ['bin/flutter_gen_command.dart', '--wrong']); |
| 42 | + expect(await process.stderr.next, |
| 43 | + equals('Could not find an option named "wrong".')); |
| 44 | + expect( |
| 45 | + await process.stderr.next, equals('usage: flutter_gen [options...]')); |
| 46 | + await process.shouldExit(0); |
| 47 | + }); |
| 48 | +} |
0 commit comments