OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library pub_cache_test; | 5 library pub_cache_test; |
6 | 6 |
| 7 import 'package:path/path.dart' as path; |
| 8 |
7 import 'descriptor.dart' as d; | 9 import 'descriptor.dart' as d; |
8 import 'test_pub.dart'; | 10 import 'test_pub.dart'; |
9 | 11 |
10 main() { | 12 main() { |
11 initConfig(); | 13 initConfig(); |
12 | 14 |
| 15 hostedDir(package) { |
| 16 return path.join(sandboxDir, cachePath, "hosted", |
| 17 "pub.dartlang.org", package); |
| 18 } |
| 19 |
13 integration('running pub cache displays error message', () { | 20 integration('running pub cache displays error message', () { |
14 schedulePub(args: ['cache'], | 21 schedulePub(args: ['cache'], |
15 output: ''' | 22 output: ''' |
16 Inspect the system cache. | 23 Inspect the system cache. |
17 | 24 |
18 Usage: pub cache list | 25 Usage: pub cache list |
19 -h, --help Print usage information for this command. | 26 -h, --help Print usage information for this command. |
20 ''', | 27 ''', |
21 error: 'The cache command expects one argument.', | 28 error: 'The cache command expects one argument.', |
22 exitCode: 64); | 29 exitCode: 64); |
(...skipping 17 matching lines...) Expand all Loading... |
40 | 47 |
41 integration('running pub cache list on empty cache', () { | 48 integration('running pub cache list on empty cache', () { |
42 // Set up a cache. | 49 // Set up a cache. |
43 d.dir(cachePath, [ | 50 d.dir(cachePath, [ |
44 d.dir('hosted', [ | 51 d.dir('hosted', [ |
45 d.dir('pub.dartlang.org', [ | 52 d.dir('pub.dartlang.org', [ |
46 ]) | 53 ]) |
47 ]) | 54 ]) |
48 ]).create(); | 55 ]).create(); |
49 | 56 |
50 schedulePub(args: ['cache', 'list'], output: '{"packages":{}}'); | 57 schedulePub(args: ['cache', 'list'], outputJson: {"packages":{}}); |
51 }); | 58 }); |
52 | 59 |
53 integration('running pub cache list', () { | 60 integration('running pub cache list', () { |
54 // Set up a cache. | 61 // Set up a cache. |
55 d.dir(cachePath, [ | 62 d.dir(cachePath, [ |
56 d.dir('hosted', [ | 63 d.dir('hosted', [ |
57 d.dir('pub.dartlang.org', [ | 64 d.dir('pub.dartlang.org', [ |
58 d.dir("foo-1.2.3", [ | 65 d.dir("foo-1.2.3", [ |
59 d.libPubspec("foo", "1.2.3"), | 66 d.libPubspec("foo", "1.2.3"), |
60 d.libDir("foo") | 67 d.libDir("foo") |
61 ]), | 68 ]), |
62 d.dir("bar-2.0.0", [ | 69 d.dir("bar-2.0.0", [ |
63 d.libPubspec("bar", "2.0.0"), | 70 d.libPubspec("bar", "2.0.0"), |
64 d.libDir("bar") ]) | 71 d.libDir("bar") ]) |
65 ]) | 72 ]) |
66 ]) | 73 ]) |
67 ]).create(); | 74 ]).create(); |
68 | 75 |
69 schedulePub(args: ['cache', 'list'], output: | 76 schedulePub(args: ['cache', 'list'], outputJson: { |
70 new RegExp(r'\{"packages":\{"bar":\{"2\.0\.0":\{"location":' | 77 "packages": { |
71 r'"[^"]+bar-2\.0\.0"\}},"foo":\{"1\.2\.3":\{"location":' | 78 "bar": {"2.0.0": {"location": hostedDir('bar-2.0.0')}}, |
72 r'"[^"]+foo-1\.2\.3"\}\}\}\}$')); | 79 "foo": {"1.2.3": {"location": hostedDir('foo-1.2.3')}} |
| 80 } |
| 81 }); |
73 }); | 82 }); |
74 | 83 |
75 integration('includes packages containing deps with bad sources', () { | 84 integration('includes packages containing deps with bad sources', () { |
76 // Set up a cache. | 85 // Set up a cache. |
77 d.dir(cachePath, [ | 86 d.dir(cachePath, [ |
78 d.dir('hosted', [ | 87 d.dir('hosted', [ |
79 d.dir('pub.dartlang.org', [ | 88 d.dir('pub.dartlang.org', [ |
80 d.dir("foo-1.2.3", [ | 89 d.dir("foo-1.2.3", [ |
81 d.libPubspec("foo", "1.2.3", deps: { "bar": {"bad": "bar"}}), | 90 d.libPubspec("foo", "1.2.3", deps: { "bar": {"bad": "bar"}}), |
82 d.libDir("foo") | 91 d.libDir("foo") |
83 ]) | 92 ]) |
84 ]) | 93 ]) |
85 ]) | 94 ]) |
86 ]).create(); | 95 ]).create(); |
87 | 96 |
88 schedulePub(args: ['cache', 'list'], output: | 97 schedulePub(args: ['cache', 'list'], outputJson: { |
89 new RegExp(r'\{"packages":\{"foo":\{"1\.2\.3":\{"location":' | 98 "packages": { |
90 r'"[^"]+foo-1\.2\.3"\}\}\}\}$')); | 99 "foo": {"1.2.3": {"location": hostedDir('foo-1.2.3')}} |
| 100 } |
| 101 }); |
91 }); | 102 }); |
92 } | 103 } |
OLD | NEW |