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

Side by Side Diff: pkg/http/test/http_test.dart

Issue 11801008: Fix tests for VM in checked mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing expectAsync1 Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/http/test/client_test.dart ('k') | pkg/http/test/request_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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS 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 http_test; 5 library http_test;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'package:http/http.dart' as http; 10 import 'package:http/http.dart' as http;
11 import 'utils.dart'; 11 import 'utils.dart';
12 12
13 main() { 13 main() {
14 group('http.', () { 14 group('http.', () {
15 setUp(startServer); 15 setUp(startServer);
16 tearDown(stopServer); 16 tearDown(stopServer);
17 17
18 test('head', () { 18 test('head', () {
19 expect(http.head(serverUrl).then(expectAsync1((response) { 19 http.head(serverUrl).then(expectAsync1((response) {
20 expect(response.statusCode, equals(200)); 20 expect(response.statusCode, equals(200));
21 expect(response.body, equals('')); 21 expect(response.body, equals(''));
22 })), completes); 22 }));
23 }); 23 });
24 24
25 test('get', () { 25 test('get', () {
26 expect(http.get(serverUrl, headers: { 26 expect(http.get(serverUrl, headers: {
27 'X-Random-Header': 'Value', 27 'X-Random-Header': 'Value',
28 'X-Other-Header': 'Other Value' 28 'X-Other-Header': 'Other Value'
29 }).then(expectAsync1((response) { 29 }).then(expectAsync1((response) {
30 expect(response.statusCode, equals(200)); 30 expect(response.statusCode, equals(200));
31 expect(response.body, parse(equals({ 31 expect(response.body, parse(equals({
32 'method': 'GET', 32 'method': 'GET',
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 }).then(expectAsync1((val) => val)), completion(parse(equals({ 155 }).then(expectAsync1((val) => val)), completion(parse(equals({
156 'method': 'GET', 156 'method': 'GET',
157 'path': '/', 157 'path': '/',
158 'headers': { 158 'headers': {
159 'content-length': ['0'], 159 'content-length': ['0'],
160 'x-random-header': ['Value'], 160 'x-random-header': ['Value'],
161 'x-other-header': ['Other Value'] 161 'x-other-header': ['Other Value']
162 }, 162 },
163 })))); 163 }))));
164 }); 164 });
165 165
166 test('read throws an error for a 4** status code', () { 166 test('read throws an error for a 4** status code', () {
167 expect(http.read(serverUrl.resolve('/error')).then((expectAsync1(x) => x)) , 167 http.read(serverUrl.resolve('/error')).catchError(expectAsync1((e) {
168 throwsHttpException); 168 expect(true, e.error is HttpException);
169 }));
169 }); 170 });
170 171
171 test('readBytes', () { 172 test('readBytes', () {
172 var future = http.readBytes(serverUrl, headers: { 173 var future = http.readBytes(serverUrl, headers: {
173 'X-Random-Header': 'Value', 174 'X-Random-Header': 'Value',
174 'X-Other-Header': 'Other Value' 175 'X-Other-Header': 'Other Value'
175 }).then(expectAsync1((bytes) => new String.fromCharCodes(bytes))); 176 }).then(expectAsync1((bytes) => new String.fromCharCodes(bytes)));
176 177
177 expect(future, completion(parse(equals({ 178 expect(future, completion(parse(equals({
178 'method': 'GET', 179 'method': 'GET',
179 'path': '/', 180 'path': '/',
180 'headers': { 181 'headers': {
181 'content-length': ['0'], 182 'content-length': ['0'],
182 'x-random-header': ['Value'], 183 'x-random-header': ['Value'],
183 'x-other-header': ['Other Value'] 184 'x-other-header': ['Other Value']
184 }, 185 },
185 })))); 186 }))));
186 }); 187 });
187 188
188 test('readBytes throws an error for a 4** status code', () { 189 test('readBytes throws an error for a 4** status code', () {
189 expect(http.readBytes(serverUrl.resolve('/error')).then((expectAsync1(x) = > x)), 190 http.readBytes(serverUrl.resolve('/error')).catchError(expectAsync1((e) {
190 throwsHttpException); 191 expect(true, e.error is HttpException);
192 }));
191 }); 193 });
192 }); 194 });
193 } 195 }
OLDNEW
« no previous file with comments | « pkg/http/test/client_test.dart ('k') | pkg/http/test/request_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698