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

Side by Side Diff: test/io_server_test.dart

Issue 1411553006: Add a Server interface. (Closed) Base URL: git@github.com:dart-lang/shelf@master
Patch Set: Code review changes Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « pubspec.yaml ('k') | test/server_handler_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, 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 @TestOn('vm')
6
7 import 'dart:async';
8 import 'dart:io';
9
10 import 'package:http/http.dart' as http;
11 import 'package:shelf/shelf_io.dart';
12 import 'package:test/test.dart';
13
14 import 'test_util.dart';
15
16 void main() {
17 var server;
18 setUp(() async {
19 server = await IOServer.bind(InternetAddress.LOOPBACK_IP_V4, 0);
20 });
21
22 tearDown(() => server.close());
23
24 test("serves HTTP requests with the mounted handler", () async {
25 server.mount(syncHandler);
26 expect(await http.read(server.url), equals('Hello from /'));
27 });
28
29 test("delays HTTP requests until a handler is mounted", () async {
30 expect(http.read(server.url), completion(equals('Hello from /')));
31 await new Future.delayed(Duration.ZERO);
32
33 server.mount(asyncHandler);
34 });
35
36 test("disallows more than one handler from being mounted", () async {
37 server.mount((_) {});
38 expect(() => server.mount((_) {}), throwsStateError);
39 expect(() => server.mount((_) {}), throwsStateError);
40 });
41 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/server_handler_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698