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:scheduled_test/scheduled_test.dart'; | 7 import 'package:scheduled_test/scheduled_test.dart'; |
8 | 8 |
9 import '../../descriptor.dart' as d; | 9 import '../../descriptor.dart' as d; |
10 import '../../test_pub.dart'; | 10 import '../../test_pub.dart'; |
11 import '../utils.dart'; | 11 import '../utils.dart'; |
12 | 12 |
13 main() { | 13 main() { |
14 integration("binds a directory to a new port", () { | 14 integration("binds a directory to a new port", () { |
15 d.dir(appPath, [ | 15 d.dir(appPath, [ |
16 d.appPubspec(), | 16 d.appPubspec(), |
17 d.dir("test", [ | 17 d.dir("test", [ |
18 d.file("index.html", "<test body>") | 18 d.file("index.html", "<test body>") |
19 ]), | 19 ]), |
20 d.dir("web", [ | 20 d.dir("web", [ |
21 d.file("index.html", "<body>") | 21 d.file("index.html", "<body>") |
22 ]) | 22 ]) |
23 ]).create(); | 23 ]).create(); |
24 | 24 |
25 pubServe(args: ["web"]); | 25 pubServe(args: ["web"], shouldGetFirst: true); |
26 | 26 |
27 // Bind the new directory. | 27 // Bind the new directory. |
28 schedule(() async { | 28 schedule(() async { |
29 var response = await expectWebSocketResult( | 29 var response = await expectWebSocketResult( |
30 "serveDirectory", {"path": "test"}, | 30 "serveDirectory", {"path": "test"}, |
31 {"url": matches(r"http://localhost:\d+")}); | 31 {"url": matches(r"http://localhost:\d+")}); |
32 | 32 |
33 var url = Uri.parse(response["url"]); | 33 var url = Uri.parse(response["url"]); |
34 registerServerPort("test", url.port); | 34 registerServerPort("test", url.port); |
35 }); | 35 }); |
36 | 36 |
37 // It should be served now. | 37 // It should be served now. |
38 requestShouldSucceed("index.html", "<test body>", root: "test"); | 38 requestShouldSucceed("index.html", "<test body>", root: "test"); |
39 | 39 |
40 // And watched. | 40 // And watched. |
41 d.dir(appPath, [ | 41 d.dir(appPath, [ |
42 d.dir("test", [ | 42 d.dir("test", [ |
43 d.file("index.html", "after") | 43 d.file("index.html", "after") |
44 ]) | 44 ]) |
45 ]).create(); | 45 ]).create(); |
46 | 46 |
47 waitForBuildSuccess(); | 47 waitForBuildSuccess(); |
48 requestShouldSucceed("index.html", "after", root: "test"); | 48 requestShouldSucceed("index.html", "after", root: "test"); |
49 | 49 |
50 endPubServe(); | 50 endPubServe(); |
51 }); | 51 }); |
52 } | 52 } |
OLD | NEW |