Chromium Code Reviews| Index: sdk/lib/_internal/pub/test/serve/utils.dart |
| diff --git a/sdk/lib/_internal/pub/test/serve/utils.dart b/sdk/lib/_internal/pub/test/serve/utils.dart |
| index 95e4da7a95c4db42a480448e65f7fd6151c3461f..13905d5141124c033307f186bff69cff39af04ae 100644 |
| --- a/sdk/lib/_internal/pub/test/serve/utils.dart |
| +++ b/sdk/lib/_internal/pub/test/serve/utils.dart |
| @@ -204,18 +204,27 @@ void endPubServe() { |
| } |
| /// Schedules an HTTP request to the running pub server with [urlPath] and |
| +/// invokes [callback] with the response. |
| +/// |
| +/// [root] indicates which server should be accessed, and defaults to "web". |
| +void scheduleRequest(String urlPath, callback(http.Response response), |
|
nweiz
2014/04/01 19:20:28
You don't need to manually pass a callback here. [
Bob Nystrom
2014/04/01 19:40:57
Yeah, I thought about that, but I figured the poin
|
| + {String root}) { |
| + schedule(() { |
| + return http.get(_getServerUrlSync(root, urlPath)).then(callback); |
| + }, "request $urlPath"); |
| +} |
| + |
| +/// Schedules an HTTP request to the running pub server with [urlPath] and |
| /// verifies that it responds with a body that matches [expectation]. |
| /// |
| /// [expectation] may either be a [Matcher] or a string to match an exact body. |
| /// [root] indicates which server should be accessed, and defaults to "web". |
| /// [headers] may be either a [Matcher] or a map to match an exact headers map. |
| void requestShouldSucceed(String urlPath, expectation, {String root, headers}) { |
| - schedule(() { |
| - return http.get(_getServerUrlSync(root, urlPath)).then((response) { |
| - if (expectation != null) expect(response.body, expectation); |
| - if (headers != null) expect(response.headers, headers); |
| - }); |
| - }, "request $urlPath"); |
| + scheduleRequest(urlPath, (response) { |
| + if (expectation != null) expect(response.body, expectation); |
| + if (headers != null) expect(response.headers, headers); |
| + }, root: root); |
| } |
| /// Schedules an HTTP request to the running pub server with [urlPath] and |
| @@ -223,11 +232,9 @@ void requestShouldSucceed(String urlPath, expectation, {String root, headers}) { |
| /// |
| /// [root] indicates which server should be accessed, and defaults to "web". |
| void requestShould404(String urlPath, {String root}) { |
| - schedule(() { |
| - return http.get(_getServerUrlSync(root, urlPath)).then((response) { |
| - expect(response.statusCode, equals(404)); |
| - }); |
| - }, "request $urlPath"); |
| + scheduleRequest(urlPath, (response) { |
| + expect(response.statusCode, equals(404)); |
| + }, root: root); |
| } |
| /// Schedules an HTTP request to the running pub server with [urlPath] and |
| @@ -243,7 +250,6 @@ void requestShouldRedirect(String urlPath, redirectTarget, {String root}) { |
| request.followRedirects = false; |
| return request.send().then((response) { |
| expect(response.statusCode ~/ 100, equals(3)); |
| - |
| expect(response.headers, containsPair('location', redirectTarget)); |
| }); |
| }, "request $urlPath"); |