Chromium Code Reviews

Side by Side Diff: mojo/public/dart/third_party/shelf/test/test_util.dart

Issue 1346773002: Stop running pub get at gclient sync time and fix build bugs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 library shelf.test_util;
6
7 import 'dart:async';
8
9 import 'package:shelf/shelf.dart';
10
11 // "hello,"
12 const HELLO_BYTES = const [104, 101, 108, 108, 111, 44];
13
14 // " world"
15 const WORLD_BYTES = const [32, 119, 111, 114, 108, 100];
16
17 /// A simple, synchronous handler for [Request].
18 ///
19 /// By default, replies with a status code 200, empty headers, and
20 /// `Hello from ${request.url.path}`.
21 Response syncHandler(Request request,
22 {int statusCode, Map<String, String> headers}) {
23 if (statusCode == null) statusCode = 200;
24 return new Response(statusCode,
25 headers: headers, body: 'Hello from ${request.requestedUri.path}');
26 }
27
28 /// Calls [syncHandler] and wraps the response in a [Future].
29 Future<Response> asyncHandler(Request request) =>
30 new Future(() => syncHandler(request));
31
32 /// Makes a simple GET request to [handler] and returns the result.
33 Future<Response> makeSimpleRequest(Handler handler) =>
34 new Future.sync(() => handler(_request));
35
36 final _request = new Request('GET', LOCALHOST_URI);
37
38 final LOCALHOST_URI = Uri.parse('http://localhost/');
OLDNEW
« no previous file with comments | « mojo/public/dart/third_party/shelf/test/test_all.dart ('k') | mojo/public/dart/third_party/shelf/tool/travis.sh » ('j') | no next file with comments »

Powered by Google App Engine