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