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 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:scheduled_test/scheduled_test.dart'; | 9 import 'package:scheduled_test/scheduled_test.dart'; |
10 | 10 |
11 import '../../descriptor.dart' as d; | 11 import '../../descriptor.dart' as d; |
12 import '../../test_pub.dart'; | 12 import '../../test_pub.dart'; |
13 import '../utils.dart'; | 13 import '../utils.dart'; |
14 | 14 |
15 main() { | 15 main() { |
16 integration("binds a directory to a new port and immediately unbinds that " | 16 integration("binds a directory to a new port and immediately unbinds that " |
17 "directory", () { | 17 "directory", () { |
18 d.dir(appPath, [ | 18 d.dir(appPath, [ |
19 d.appPubspec(), | 19 d.appPubspec(), |
20 d.dir("test", [ | 20 d.dir("test", [ |
21 d.file("index.html", "<test body>") | 21 d.file("index.html", "<test body>") |
22 ]), | 22 ]), |
23 d.dir("web", [ | 23 d.dir("web", [ |
24 d.file("index.html", "<body>") | 24 d.file("index.html", "<body>") |
25 ]) | 25 ]) |
26 ]).create(); | 26 ]).create(); |
27 | 27 |
28 pubServe(args: ["web"], shouldGetFirst: true); | 28 pubGet(); |
| 29 pubServe(args: ["web"]); |
29 | 30 |
30 // We call [webSocketRequest] outside of the [schedule] call below because | 31 // We call [webSocketRequest] outside of the [schedule] call below because |
31 // we need it to schedule the sending of the request to guarantee that the | 32 // we need it to schedule the sending of the request to guarantee that the |
32 // serve is sent before the unserve. | 33 // serve is sent before the unserve. |
33 var serveRequest = webSocketRequest("serveDirectory", {"path": "test"}); | 34 var serveRequest = webSocketRequest("serveDirectory", {"path": "test"}); |
34 var unserveRequest = webSocketRequest("unserveDirectory", {"path": "test"}); | 35 var unserveRequest = webSocketRequest("unserveDirectory", {"path": "test"}); |
35 | 36 |
36 schedule(() { | 37 schedule(() { |
37 return Future.wait([serveRequest, unserveRequest]).then((results) { | 38 return Future.wait([serveRequest, unserveRequest]).then((results) { |
38 expect(results[0], contains("result")); | 39 expect(results[0], contains("result")); |
39 expect(results[1], contains("result")); | 40 expect(results[1], contains("result")); |
40 // These results should be equal since "serveDirectory" returns the URL | 41 // These results should be equal since "serveDirectory" returns the URL |
41 // of the new server and "unserveDirectory" returns the URL of the | 42 // of the new server and "unserveDirectory" returns the URL of the |
42 // server that was turned off. We're asserting that the same server was | 43 // server that was turned off. We're asserting that the same server was |
43 // both started and stopped. | 44 // both started and stopped. |
44 expect(results[0]["result"]["url"], matches(r"http://localhost:\d+")); | 45 expect(results[0]["result"]["url"], matches(r"http://localhost:\d+")); |
45 expect(results[0]["result"], equals(results[1]["result"])); | 46 expect(results[0]["result"], equals(results[1]["result"])); |
46 }); | 47 }); |
47 }); | 48 }); |
48 | 49 |
49 endPubServe(); | 50 endPubServe(); |
50 }); | 51 }); |
51 } | 52 } |
OLD | NEW |