OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.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_tests; | 5 library pub_tests; |
6 | 6 |
7 import 'package:json_rpc_2/error_code.dart' as rpc_error_code; | 7 import 'package:json_rpc_2/error_code.dart' as rpc_error_code; |
8 import 'package:path/path.dart' as p; | 8 import 'package:path/path.dart' as p; |
9 | 9 |
10 import '../../descriptor.dart' as d; | 10 import '../../descriptor.dart' as d; |
11 import '../../test_pub.dart'; | 11 import '../../test_pub.dart'; |
12 import '../utils.dart'; | 12 import '../utils.dart'; |
13 | 13 |
14 main() { | 14 main() { |
15 // TODO(rnystrom): Split into independent tests. | 15 // TODO(rnystrom): Split into independent tests. |
16 initConfig(); | 16 initConfig(); |
17 integration("pathToUrls errors on bad inputs", () { | 17 integration("pathToUrls errors on bad inputs", () { |
18 d.dir("foo", [ | 18 d.dir( |
19 d.libPubspec("foo", "1.0.0"), | 19 "foo", |
20 d.dir("web", [ | 20 [ |
21 d.file("foo.txt", "foo") | 21 d.libPubspec("foo", "1.0.0"), |
22 ]) | 22 d.dir("web", [d.file("foo.txt", "foo")])]).create(); |
23 ]).create(); | |
24 | 23 |
25 d.dir(appPath, [ | 24 d.dir(appPath, [d.appPubspec({ |
26 d.appPubspec({"foo": {"path": "../foo"}}), | 25 "foo": { |
27 d.file("top-level.txt", "top-level"), | 26 "path": "../foo" |
28 d.dir("bin", [ | 27 } |
29 d.file("foo.txt", "foo"), | 28 }), |
30 ]), | 29 d.file("top-level.txt", "top-level"), |
31 d.dir("lib", [ | 30 d.dir("bin", [d.file("foo.txt", "foo"),]), |
32 d.file("myapp.dart", "myapp"), | 31 d.dir("lib", [d.file("myapp.dart", "myapp"),])]).create(); |
33 ]) | |
34 ]).create(); | |
35 | 32 |
36 pubServe(shouldGetFirst: true); | 33 pubServe(shouldGetFirst: true); |
37 | 34 |
38 // Bad arguments. | 35 // Bad arguments. |
39 expectWebSocketError("pathToUrls", {"path": 123}, | 36 expectWebSocketError("pathToUrls", { |
| 37 "path": 123 |
| 38 }, |
40 rpc_error_code.INVALID_PARAMS, | 39 rpc_error_code.INVALID_PARAMS, |
41 'Parameter "path" for method "pathToUrls" must be a string, but was ' | 40 'Parameter "path" for method "pathToUrls" must be a string, but was ' '1
23.'); |
42 '123.'); | |
43 | 41 |
44 expectWebSocketError("pathToUrls", {"path": "main.dart", "line": 12.34}, | 42 expectWebSocketError("pathToUrls", { |
| 43 "path": "main.dart", |
| 44 "line": 12.34 |
| 45 }, |
45 rpc_error_code.INVALID_PARAMS, | 46 rpc_error_code.INVALID_PARAMS, |
46 'Parameter "line" for method "pathToUrls" must be an integer, but was ' | 47 'Parameter "line" for method "pathToUrls" must be an integer, but was ' |
47 '12.34.'); | 48 '12.34.'); |
48 | 49 |
49 // Unserved directories. | 50 // Unserved directories. |
50 expectNotServed(p.join('bin', 'foo.txt')); | 51 expectNotServed(p.join('bin', 'foo.txt')); |
51 expectNotServed(p.join('nope', 'foo.txt')); | 52 expectNotServed(p.join('nope', 'foo.txt')); |
52 expectNotServed(p.join("..", "bar", "lib", "bar.txt")); | 53 expectNotServed(p.join("..", "bar", "lib", "bar.txt")); |
53 expectNotServed(p.join("..", "foo", "web", "foo.txt")); | 54 expectNotServed(p.join("..", "foo", "web", "foo.txt")); |
54 | 55 |
55 endPubServe(); | 56 endPubServe(); |
56 }); | 57 }); |
57 } | 58 } |
58 | 59 |
59 void expectNotServed(String path) { | 60 void expectNotServed(String path) { |
60 expectWebSocketError("pathToUrls", {"path": path}, NOT_SERVED, | 61 expectWebSocketError("pathToUrls", { |
61 'Asset path "$path" is not currently being served.'); | 62 "path": path |
| 63 }, NOT_SERVED, 'Asset path "$path" is not currently being served.'); |
62 } | 64 } |
OLD | NEW |