| 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; | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|  25       d.appPubspec({"foo": {"path": "../foo"}}), |  25       d.appPubspec({"foo": {"path": "../foo"}}), | 
|  26       d.file("top-level.txt", "top-level"), |  26       d.file("top-level.txt", "top-level"), | 
|  27       d.dir("bin", [ |  27       d.dir("bin", [ | 
|  28         d.file("foo.txt", "foo"), |  28         d.file("foo.txt", "foo"), | 
|  29       ]), |  29       ]), | 
|  30       d.dir("lib", [ |  30       d.dir("lib", [ | 
|  31         d.file("myapp.dart", "myapp"), |  31         d.file("myapp.dart", "myapp"), | 
|  32       ]) |  32       ]) | 
|  33     ]).create(); |  33     ]).create(); | 
|  34  |  34  | 
|  35     pubServe(shouldGetFirst: true); |  35     pubGet(); | 
 |  36     pubServe(); | 
|  36  |  37  | 
|  37     // Bad arguments. |  38     // Bad arguments. | 
|  38     expectWebSocketError("pathToUrls", {"path": 123}, |  39     expectWebSocketError("pathToUrls", {"path": 123}, | 
|  39         rpc_error_code.INVALID_PARAMS, |  40         rpc_error_code.INVALID_PARAMS, | 
|  40         'Parameter "path" for method "pathToUrls" must be a string, but was ' |  41         'Parameter "path" for method "pathToUrls" must be a string, but was ' | 
|  41             '123.'); |  42             '123.'); | 
|  42  |  43  | 
|  43     expectWebSocketError("pathToUrls", {"path": "main.dart", "line": 12.34}, |  44     expectWebSocketError("pathToUrls", {"path": "main.dart", "line": 12.34}, | 
|  44         rpc_error_code.INVALID_PARAMS, |  45         rpc_error_code.INVALID_PARAMS, | 
|  45         'Parameter "line" for method "pathToUrls" must be an integer, but was ' |  46         'Parameter "line" for method "pathToUrls" must be an integer, but was ' | 
|  46             '12.34.'); |  47             '12.34.'); | 
|  47  |  48  | 
|  48     // Unserved directories. |  49     // Unserved directories. | 
|  49     expectNotServed(p.join('bin', 'foo.txt')); |  50     expectNotServed(p.join('bin', 'foo.txt')); | 
|  50     expectNotServed(p.join('nope', 'foo.txt')); |  51     expectNotServed(p.join('nope', 'foo.txt')); | 
|  51     expectNotServed(p.join("..", "bar", "lib", "bar.txt")); |  52     expectNotServed(p.join("..", "bar", "lib", "bar.txt")); | 
|  52     expectNotServed(p.join("..", "foo", "web", "foo.txt")); |  53     expectNotServed(p.join("..", "foo", "web", "foo.txt")); | 
|  53  |  54  | 
|  54     endPubServe(); |  55     endPubServe(); | 
|  55   }); |  56   }); | 
|  56 } |  57 } | 
|  57  |  58  | 
|  58 void expectNotServed(String path) { |  59 void expectNotServed(String path) { | 
|  59   expectWebSocketError("pathToUrls", {"path": path}, NOT_SERVED, |  60   expectWebSocketError("pathToUrls", {"path": path}, NOT_SERVED, | 
|  60       'Asset path "$path" is not currently being served.'); |  61       'Asset path "$path" is not currently being served.'); | 
|  61 } |  62 } | 
| OLD | NEW |