|
| 1 | +import 'dart:io'; |
| 2 | + |
| 3 | +import 'package:test/test.dart'; |
| 4 | + |
| 5 | +void main() { |
| 6 | + group('MetroCommand', () { |
| 7 | + group('CLI integration', () { |
| 8 | + test('help should list metro command', () async { |
| 9 | + final result = await Process.run( |
| 10 | + 'dart', |
| 11 | + ['run', 'bin/nylo.dart', '--help'], |
| 12 | + ); |
| 13 | + |
| 14 | + expect(result.exitCode, equals(0)); |
| 15 | + expect(result.stdout, contains('metro')); |
| 16 | + expect(result.stdout, contains('metro <command>')); |
| 17 | + }); |
| 18 | + |
| 19 | + test('metro should be a recognized command', () async { |
| 20 | + // Running metro without being in a Nylo project will fail, |
| 21 | + // but it should NOT trigger the "Unknown command" error path. |
| 22 | + final result = await Process.run( |
| 23 | + 'dart', |
| 24 | + ['run', 'bin/nylo.dart', 'metro'], |
| 25 | + ); |
| 26 | + |
| 27 | + expect(result.stderr, isNot(contains('Unknown command'))); |
| 28 | + }, timeout: Timeout(Duration(seconds: 30))); |
| 29 | + |
| 30 | + test('metro with arguments should be a recognized command', () async { |
| 31 | + final result = await Process.run( |
| 32 | + 'dart', |
| 33 | + ['run', 'bin/nylo.dart', 'metro', 'make:model', 'User'], |
| 34 | + ); |
| 35 | + |
| 36 | + expect(result.stderr, isNot(contains('Unknown command'))); |
| 37 | + }, timeout: Timeout(Duration(seconds: 30))); |
| 38 | + |
| 39 | + test('metro example should appear in help', () async { |
| 40 | + final result = await Process.run( |
| 41 | + 'dart', |
| 42 | + ['run', 'bin/nylo.dart', '--help'], |
| 43 | + ); |
| 44 | + |
| 45 | + expect(result.stdout, contains('nylo metro')); |
| 46 | + }); |
| 47 | + }); |
| 48 | + }); |
| 49 | +} |
0 commit comments