| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.file | 1 // Copyright (c) 2013, 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 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 } | 253 } |
| 254 | 254 |
| 255 /// Schedules an HTTP request to the running pub server with [urlPath] and | 255 /// Schedules an HTTP request to the running pub server with [urlPath] and |
| 256 /// verifies that it responds with a body that matches [expectation]. | 256 /// verifies that it responds with a body that matches [expectation]. |
| 257 /// | 257 /// |
| 258 /// [expectation] may either be a [Matcher] or a string to match an exact body. | 258 /// [expectation] may either be a [Matcher] or a string to match an exact body. |
| 259 /// [root] indicates which server should be accessed, and defaults to "web". | 259 /// [root] indicates which server should be accessed, and defaults to "web". |
| 260 /// [headers] may be either a [Matcher] or a map to match an exact headers map. | 260 /// [headers] may be either a [Matcher] or a map to match an exact headers map. |
| 261 void requestShouldSucceed(String urlPath, expectation, {String root, headers}) { | 261 void requestShouldSucceed(String urlPath, expectation, {String root, headers}) { |
| 262 scheduleRequest(urlPath, root: root).then((response) { | 262 scheduleRequest(urlPath, root: root).then((response) { |
| 263 expect(response.statusCode, equals(200)); |
| 263 if (expectation != null) expect(response.body, expectation); | 264 if (expectation != null) expect(response.body, expectation); |
| 264 if (headers != null) expect(response.headers, headers); | 265 if (headers != null) expect(response.headers, headers); |
| 265 }); | 266 }); |
| 266 } | 267 } |
| 267 | 268 |
| 268 /// Schedules an HTTP request to the running pub server with [urlPath] and | 269 /// Schedules an HTTP request to the running pub server with [urlPath] and |
| 269 /// verifies that it responds with a 404. | 270 /// verifies that it responds with a 404. |
| 270 /// | 271 /// |
| 271 /// [root] indicates which server should be accessed, and defaults to "web". | 272 /// [root] indicates which server should be accessed, and defaults to "web". |
| 272 void requestShould404(String urlPath, {String root}) { | 273 void requestShould404(String urlPath, {String root}) { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 /// included. Unlike [getServerUrl], this should only be called after the ports | 491 /// included. Unlike [getServerUrl], this should only be called after the ports |
| 491 /// are known. | 492 /// are known. |
| 492 String _getServerUrlSync([String root, String path]) { | 493 String _getServerUrlSync([String root, String path]) { |
| 493 if (root == null) root = 'web'; | 494 if (root == null) root = 'web'; |
| 494 expect(_ports, contains(root)); | 495 expect(_ports, contains(root)); |
| 495 var url = "http://localhost:${_ports[root]}"; | 496 var url = "http://localhost:${_ports[root]}"; |
| 496 if (path != null) url = "$url/$path"; | 497 if (path != null) url = "$url/$path"; |
| 497 return url; | 498 return url; |
| 498 } | 499 } |
| 499 | 500 |
| OLD | NEW |