Chromium Code Reviews| Index: pkg/http_server/test/http_body_test.dart |
| diff --git a/tests/standalone/io/http_body_test.dart b/pkg/http_server/test/http_body_test.dart |
| similarity index 81% |
| rename from tests/standalone/io/http_body_test.dart |
| rename to pkg/http_server/test/http_body_test.dart |
| index 419e3810791f30a32b6b0165ea94151f7fa6aeaa..031ee5d67c3a63ee8406d2de706475375f8a80f1 100644 |
| --- a/tests/standalone/io/http_body_test.dart |
| +++ b/pkg/http_server/test/http_body_test.dart |
| @@ -5,7 +5,8 @@ |
| import 'dart:io'; |
| import 'dart:utf'; |
| -import 'package:expect/expect.dart'; |
| +import 'package:http_server/http_server.dart'; |
| +import 'package:unittest/unittest.dart'; |
| void testHttpClientResponseBody() { |
| void test(String mimeType, |
| @@ -30,20 +31,17 @@ void testHttpClientResponseBody() { |
| .then((request) => request.close()) |
| .then(HttpBodyHandler.processResponse) |
| .then((body) { |
| - if (shouldFail) Expect.fail("Error expected"); |
| - Expect.equals(type, body.type); |
| - Expect.isNotNull(body.response); |
| + if (shouldFail) throw "Error expected"; |
| + expect(body.type, equals(type)); |
| + expect(body.response, isNotNull); |
| switch (type) { |
| case "text": |
| - Expect.equals(expectedBody, body.body); |
| - break; |
| - |
| case "json": |
| - Expect.mapEquals(expectedBody, body.body); |
| + expect(body.body, equals(expectedBody)); |
| break; |
| default: |
| - Expect.fail("bad body type"); |
| + throw "bad body type"; |
| } |
| }, onError: (error) { |
| if (!shouldFail) throw error; |
| @@ -95,52 +93,48 @@ void testHttpServerRequestBody() { |
| HttpServer.bind("127.0.0.1", 0).then((server) { |
| server.transform(new HttpBodyHandler(defaultEncoding: defaultEncoding)) |
| .listen((body) { |
| - if (shouldFail) Expect.fail("Error expected"); |
| - Expect.equals(type, body.type); |
| + if (shouldFail) throw "Error expected"; |
| + expect(body.type, equals(type)); |
| switch (type) { |
| case "text": |
| - Expect.equals(body.contentType.mimeType, "text/plain"); |
| - Expect.equals(expectedBody, body.body); |
| + expect(body.contentType.mimeType, equals("text/plain")); |
| + expect(body.body, equals(expectedBody)); |
| break; |
| case "json": |
| - Expect.equals(body.contentType.mimeType, "application/json"); |
| - Expect.mapEquals(expectedBody, body.body); |
| + expect(body.contentType.mimeType, equals("application/json")); |
| + expect(body.body, equals(expectedBody)); |
| break; |
| case "binary": |
| - Expect.equals(body.contentType, null); |
| - Expect.listEquals(expectedBody, body.body); |
| + expect(body.contentType, isNull); |
| + expect(body.body, equals(expectedBody)); |
| break; |
| case "form": |
| var mimeType = body.contentType.mimeType; |
| - Expect.isTrue( |
| + expect( |
|
Bill Hesse
2013/07/03 11:30:27
expect(mimeType, anyOf(equals('multipart/form-data
Anders Johnsen
2013/07/12 10:45:57
Done.
|
| mimeType == 'multipart/form-data' || |
| - mimeType == 'application/x-www-form-urlencoded'); |
| - Expect.setEquals(expectedBody.keys.toSet(), |
| - body.body.keys.toSet()); |
| + mimeType == 'application/x-www-form-urlencoded', |
| + isTrue); |
| + expect(body.body.keys.toSet(), |
| + equals(expectedBody.keys.toSet())); |
| for (var key in expectedBody.keys) { |
| if (body.body[key] is HttpBodyFileUpload) { |
| - Expect.equals(expectedBody[key]['contentType'], |
| - body.body[key].contentType.toString()); |
| - Expect.equals(expectedBody[key]['filename'], |
| - body.body[key].filename); |
| - if (body.body[key].content is String) { |
| - Expect.equals(expectedBody[key]['content'], |
| - body.body[key].content); |
| - } else { |
| - Expect.listEquals(expectedBody[key]['content'], |
| - body.body[key].content); |
| - } |
| + expect(body.body[key].contentType.toString(), |
| + equals(expectedBody[key]['contentType'])); |
| + expect(body.body[key].filename, |
| + equals(expectedBody[key]['filename'])); |
| + expect(body.body[key].content, |
| + equals(expectedBody[key]['content'])); |
| } else { |
| - Expect.equals(expectedBody[key], body.body[key]); |
| + expect(body.body[key], equals(expectedBody[key])); |
| } |
| } |
| break; |
| default: |
| - Expect.fail("bad body type"); |
| + throw "bad body type"; |
| } |
| body.response.close(); |
| }, onError: (error) { |
| @@ -159,7 +153,7 @@ void testHttpServerRequestBody() { |
| }) |
| .then((response) { |
| if (shouldFail) { |
| - Expect.equals(HttpStatus.BAD_REQUEST, response.statusCode); |
| + expect(response.statusCode, equals(HttpStatus.BAD_REQUEST)); |
| } |
| response.fold(null, (x, y) {}); |
| client.close(); |