Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: sdk/lib/_internal/pub/test/serve/utils.dart

Issue 219733002: Make a slightly better 404 page for pub serve. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/pub/test/serve/404_page_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6b005c6bac7c36257461abde23a11965044aef45 100644
--- a/sdk/lib/_internal/pub/test/serve/utils.dart
+++ b/sdk/lib/_internal/pub/test/serve/utils.dart
@@ -204,18 +204,26 @@ 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".
+Future<http.Response> scheduleRequest(String urlPath, {String root}) {
+ return schedule(() {
+ return http.get(_getServerUrlSync(root, urlPath));
+ }, "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, root: root).then((response) {
+ if (expectation != null) expect(response.body, expectation);
+ if (headers != null) expect(response.headers, headers);
+ });
}
/// Schedules an HTTP request to the running pub server with [urlPath] and
@@ -223,11 +231,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, root: root).then((response) {
+ expect(response.statusCode, equals(404));
+ });
}
/// Schedules an HTTP request to the running pub server with [urlPath] and
@@ -243,7 +249,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");
« no previous file with comments | « sdk/lib/_internal/pub/test/serve/404_page_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698