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

Side by Side Diff: test/io/http_test.dart

Issue 1243783002: Add a shortcut for PATCH. (Closed) Base URL: git@github.com:dart-lang/http@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « pubspec.yaml ('k') | no next file » | 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) 2014, the Dart project authors. Please see the AUTHORS file 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 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.io.http_test; 5 library http.test.io.http_test;
6 6
7 import 'package:http/http.dart' as http; 7 import 'package:http/http.dart' as http;
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import 'utils.dart'; 10 import 'utils.dart';
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 'user-agent': ['Dart'], 246 'user-agent': ['Dart'],
247 'x-random-header': ['Value'], 247 'x-random-header': ['Value'],
248 'x-other-header': ['Other Value'] 248 'x-other-header': ['Other Value']
249 }, 249 },
250 'body': 'some-field=value&other-field=other+value' 250 'body': 'some-field=value&other-field=other+value'
251 }))); 251 })));
252 }), completes); 252 }), completes);
253 }), completes); 253 }), completes);
254 }); 254 });
255 255
256 test('patch', () {
257 expect(startServer().then((_) {
258 expect(http.patch(serverUrl, headers: {
259 'X-Random-Header': 'Value',
260 'X-Other-Header': 'Other Value',
261 'Content-Type': 'text/plain',
262 'User-Agent': 'Dart'
263 }).then((response) {
264 expect(response.statusCode, equals(200));
265 expect(response.body, parse(equals({
266 'method': 'PATCH',
267 'path': '/',
268 'headers': {
269 'accept-encoding': ['gzip'],
270 'content-length': ['0'],
271 'content-type': ['text/plain'],
272 'user-agent': ['Dart'],
273 'x-random-header': ['Value'],
274 'x-other-header': ['Other Value']
275 }
276 })));
277 }), completes);
278 }), completes);
279 });
280
281 test('patch with string', () {
282 expect(startServer().then((_) {
283 expect(http.patch(serverUrl, headers: {
284 'X-Random-Header': 'Value',
285 'X-Other-Header': 'Other Value',
286 'User-Agent': 'Dart'
287 }, body: 'request body').then((response) {
288 expect(response.statusCode, equals(200));
289 expect(response.body, parse(equals({
290 'method': 'PATCH',
291 'path': '/',
292 'headers': {
293 'content-type': ['text/plain; charset=utf-8'],
294 'content-length': ['12'],
295 'accept-encoding': ['gzip'],
296 'user-agent': ['Dart'],
297 'x-random-header': ['Value'],
298 'x-other-header': ['Other Value']
299 },
300 'body': 'request body'
301 })));
302 }), completes);
303 }), completes);
304 });
305
306 test('patch with bytes', () {
307 expect(startServer().then((_) {
308 expect(http.patch(serverUrl, headers: {
309 'X-Random-Header': 'Value',
310 'X-Other-Header': 'Other Value',
311 'User-Agent': 'Dart'
312 }, body: [104, 101, 108, 108, 111]).then((response) {
313 expect(response.statusCode, equals(200));
314 expect(response.body, parse(equals({
315 'method': 'PATCH',
316 'path': '/',
317 'headers': {
318 'content-length': ['5'],
319 'accept-encoding': ['gzip'],
320 'user-agent': ['Dart'],
321 'x-random-header': ['Value'],
322 'x-other-header': ['Other Value']
323 },
324 'body': [104, 101, 108, 108, 111]
325 })));
326 }), completes);
327 }), completes);
328 });
329
330 test('patch with fields', () {
331 expect(startServer().then((_) {
332 expect(http.patch(serverUrl, headers: {
333 'X-Random-Header': 'Value',
334 'X-Other-Header': 'Other Value',
335 'User-Agent': 'Dart'
336 }, body: {
337 'some-field': 'value',
338 'other-field': 'other value'
339 }).then((response) {
340 expect(response.statusCode, equals(200));
341 expect(response.body, parse(equals({
342 'method': 'PATCH',
343 'path': '/',
344 'headers': {
345 'content-type': [
346 'application/x-www-form-urlencoded; charset=utf-8'
347 ],
348 'content-length': ['40'],
349 'accept-encoding': ['gzip'],
350 'user-agent': ['Dart'],
351 'x-random-header': ['Value'],
352 'x-other-header': ['Other Value']
353 },
354 'body': 'some-field=value&other-field=other+value'
355 })));
356 }), completes);
357 }), completes);
358 });
359
256 test('delete', () { 360 test('delete', () {
257 expect(startServer().then((_) { 361 expect(startServer().then((_) {
258 expect(http.delete(serverUrl, headers: { 362 expect(http.delete(serverUrl, headers: {
259 'X-Random-Header': 'Value', 363 'X-Random-Header': 'Value',
260 'X-Other-Header': 'Other Value', 364 'X-Other-Header': 'Other Value',
261 'User-Agent': 'Dart' 365 'User-Agent': 'Dart'
262 }).then((response) { 366 }).then((response) {
263 expect(response.statusCode, equals(200)); 367 expect(response.statusCode, equals(200));
264 expect(response.body, parse(equals({ 368 expect(response.body, parse(equals({
265 'method': 'DELETE', 369 'method': 'DELETE',
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 }); 429 });
326 430
327 test('readBytes throws an error for a 4** status code', () { 431 test('readBytes throws an error for a 4** status code', () {
328 expect(startServer().then((_) { 432 expect(startServer().then((_) {
329 expect(http.readBytes(serverUrl.resolve('/error')), 433 expect(http.readBytes(serverUrl.resolve('/error')),
330 throwsClientException); 434 throwsClientException);
331 }), completes); 435 }), completes);
332 }); 436 });
333 }); 437 });
334 } 438 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698