OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library pub_cache_test; | |
6 | |
7 import 'dart:io'; | |
8 import 'dart:json' as json; | |
9 | |
10 import 'package:scheduled_test/scheduled_test.dart'; | |
11 | |
12 import '../../pub/io.dart'; | |
13 import 'descriptor.dart' as d; | |
14 import 'test_pub.dart'; | |
15 | |
16 main() { | |
17 initConfig(); | |
18 | |
19 integration('running pub cache displays error message', () { | |
20 schedulePub(args: ['cache'], | |
21 output: ''' | |
22 Inspect the system cache. | |
23 | |
24 Usage: pub cache list | |
25 ''', | |
26 error: 'The cache command expects one argument.', | |
27 exitCode: 64); | |
28 }); | |
29 | |
30 integration('running pub cache foo displays error message', () { | |
31 schedulePub(args: ['cache' ,'foo'], | |
32 output: ''' | |
33 Inspect the system cache. | |
34 | |
35 Usage: pub cache list | |
36 ''', | |
37 error: 'Unknown cache command "foo".', | |
38 exitCode: 64); | |
39 }); | |
40 | |
41 integration('running pub cache list when there is no cache', () { | |
42 schedulePub(args: ['cache', 'list'], output: '{"packages":{}}'); | |
43 }); | |
44 | |
45 integration('running pub cache list on empty cache', () { | |
46 // Set up a cache. | |
47 d.dir(cachePath, [ | |
48 d.dir('hosted', [ | |
49 d.dir('pub.dartlang.org', [ | |
50 ]) | |
51 ]) | |
52 ]).create(); | |
53 | |
54 schedulePub(args: ['cache', 'list'], output: '{"packages":{}}'); | |
55 }); | |
56 | |
57 integration('running pub cache list', () { | |
58 // Set up a cache. | |
59 d.dir(cachePath, [ | |
60 d.dir('hosted', [ | |
61 d.dir('pub.dartlang.org', [ | |
62 d.dir("foo-1.2.3", [ | |
63 d.libPubspec("foo", "1.2.3"), | |
64 d.libDir("foo") | |
65 ]), | |
66 d.dir("bar-2.0.0", [ | |
67 d.libPubspec("bar", "2.0.0"), | |
68 d.libDir("bar") ]) | |
69 ]) | |
70 ]) | |
71 ]).create(); | |
72 | |
73 schedulePub(args: ['cache', 'list'], output: | |
74 new RegExp(r'\{"packages":\{"bar":\{"version":"2\.0\.0","location":' | |
75 r'"[^"]+bar-2\.0\.0"\},"foo":\{"version":"1\.2\.3","location":' | |
76 r'"[^"]+foo-1\.2\.3"\}\}\}$')); | |
77 }); | |
78 | |
79 } | |
OLD | NEW |