Chromium Code Reviews| Index: utils/tests/pub/pub_tests.dart |
| diff --git a/utils/tests/pub/pub_tests.dart b/utils/tests/pub/pub_tests.dart |
| index ea13565766b6c8942cb7b397a3e23ec73fcca7e4..e0cbc23145b68739f8585c38bdc8bb3b59fae86d 100644 |
| --- a/utils/tests/pub/pub_tests.dart |
| +++ b/utils/tests/pub/pub_tests.dart |
| @@ -9,40 +9,56 @@ |
| #import('test_pub.dart'); |
| #import('../../../lib/unittest/unittest.dart'); |
| -main() { |
| - group('running pub with no command', () { |
| - testPub('displays usage', |
| - args: [], |
| - output: ''' |
| - Pub is a package manager for Dart. |
| +final USAGE_STRING = """ |
| + Pub is a package manager for Dart. |
| - Usage: |
| + Usage: |
| - pub command [arguments] |
| + pub command [arguments] |
| - The commands are: |
| + The commands are: |
| - list print the contents of repositories |
| - version print Pub version |
| + list print the contents of repositories |
| + update update a package's dependencies |
| + version print Pub version |
|
nweiz
2012/04/25 20:49:41
Since this output isn't sorted, this test is poten
Bob Nystrom
2012/04/25 22:56:40
It is sorted. See pub.dart:98.
nweiz
2012/04/25 23:09:22
Oh, I see. I was confused by the TODO about the so
|
| - Use "pub help [command]" for more information about a command.'''); |
| - }); |
| + Use "pub help [command]" for more information about a command. |
| + """; |
| + |
| +final VERSION_STRING = ''' |
| + Pub 0.0.0 |
| + '''; |
| + |
| +main() { |
| + testPub('running pub with no command displays usage', |
| + args: [], |
| + output: USAGE_STRING); |
| + |
| + testPub('running pub with just --help displays usage', |
| + args: ['--help'], |
| + output: USAGE_STRING); |
|
nweiz
2012/04/25 20:49:41
May as well test for just "help" too.
Bob Nystrom
2012/04/25 22:56:40
Help will be a full command (so you can do "help [
|
| + |
| + testPub('running pub with just --version displays version', |
| + args: ['--version'], |
| + output: VERSION_STRING); |
| group('an unknown command', () { |
| testPub('displays an error message', |
| args: ['quylthulg'], |
| output: ''' |
| Unknown command "quylthulg". |
| - Run "pub help" to see available commands.''', |
| + Run "pub help" to see available commands. |
| + ''', |
| exitCode: 64); |
| }); |
| - listCommand(); |
| - versionCommand(); |
| + group('pub list', listCommand); |
| + group('pub update', updateCommand); |
| + group('pub version', versionCommand); |
| } |
| listCommand() { |
| - group('list cache', () { |
| + group('cache', () { |
| testPub('treats an empty directory as a package', |
| cache: [ |
| dir('apple'), |
| @@ -53,14 +69,56 @@ listCommand() { |
| output: ''' |
| apple |
| banana |
| - cherry'''); |
| + cherry |
| + '''); |
| }); |
| } |
| +updateCommand() { |
| + testPub('adds a dependent package', |
| + cache: [ |
| + dir('foo', [ |
| + file('foo.dart', 'main() => "foo";') |
| + ]) |
| + ], |
| + app: dir('myapp', [ |
| + file('pubspec', 'foo') |
| + ]), |
| + args: ['update'], |
| + expectedPackageDir: [ |
| + dir('foo', [ |
| + file('foo.dart', 'main() => "foo";') |
| + ]) |
| + ], |
| + output: ''); |
| + |
| + testPub('adds a transitively dependent package', |
| + cache: [ |
| + dir('foo', [ |
| + file('foo.dart', 'main() => "foo";'), |
| + file('pubspec', 'bar') |
| + ]), |
| + dir('bar', [ |
| + file('bar.dart', 'main() => "bar";'), |
| + ]) |
| + ], |
| + app: dir('myapp', [ |
| + file('pubspec', 'foo') |
| + ]), |
| + args: ['update'], |
| + expectedPackageDir: [ |
| + dir('foo', [ |
| + file('foo.dart', 'main() => "foo";') |
| + ]), |
| + dir('bar', [ |
| + file('bar.dart', 'main() => "bar";'), |
| + ]) |
| + ], |
| + output: ''); |
| +} |
| + |
| versionCommand() { |
| - group('the version command', () { |
| - testPub('displays the current version', |
| - args: ['version'], |
| - output: 'Pub 0.0.0'); |
| - }); |
| + testPub('displays the current version', |
| + args: ['version'], |
| + output: VERSION_STRING); |
| } |