OLD | NEW |
(Empty) | |
| 1 library pub_tests; |
| 2 import 'package:json_rpc_2/error_code.dart' as rpc_error_code; |
| 3 import 'package:path/path.dart' as p; |
| 4 import '../../descriptor.dart' as d; |
| 5 import '../../test_pub.dart'; |
| 6 import '../utils.dart'; |
| 7 main() { |
| 8 initConfig(); |
| 9 integration("pathToUrls errors on bad inputs", () { |
| 10 d.dir( |
| 11 "foo", |
| 12 [ |
| 13 d.libPubspec("foo", "1.0.0"), |
| 14 d.dir("web", [d.file("foo.txt", "foo")])]).create(); |
| 15 d.dir(appPath, [d.appPubspec({ |
| 16 "foo": { |
| 17 "path": "../foo" |
| 18 } |
| 19 }), |
| 20 d.file("top-level.txt", "top-level"), |
| 21 d.dir("bin", [d.file("foo.txt", "foo")]), |
| 22 d.dir("lib", [d.file("myapp.dart", "myapp")])]).create(); |
| 23 pubServe(shouldGetFirst: true); |
| 24 expectWebSocketError("pathToUrls", { |
| 25 "path": 123 |
| 26 }, |
| 27 rpc_error_code.INVALID_PARAMS, |
| 28 'Parameter "path" for method "pathToUrls" must be a string, but was ' '1
23.'); |
| 29 expectWebSocketError("pathToUrls", { |
| 30 "path": "main.dart", |
| 31 "line": 12.34 |
| 32 }, |
| 33 rpc_error_code.INVALID_PARAMS, |
| 34 'Parameter "line" for method "pathToUrls" must be an integer, but was ' |
| 35 '12.34.'); |
| 36 expectNotServed(p.join('bin', 'foo.txt')); |
| 37 expectNotServed(p.join('nope', 'foo.txt')); |
| 38 expectNotServed(p.join("..", "bar", "lib", "bar.txt")); |
| 39 expectNotServed(p.join("..", "foo", "web", "foo.txt")); |
| 40 endPubServe(); |
| 41 }); |
| 42 } |
| 43 void expectNotServed(String path) { |
| 44 expectWebSocketError("pathToUrls", { |
| 45 "path": path |
| 46 }, NOT_SERVED, 'Asset path "$path" is not currently being served.'); |
| 47 } |
OLD | NEW |