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

Unified Diff: pkg/http/test/http_test.dart

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/http/test/client_test.dart ('k') | pkg/http/test/request_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/test/http_test.dart
diff --git a/pkg/http/test/http_test.dart b/pkg/http/test/http_test.dart
index 48eada06ef163a70c6581bae5a3b38427f9fbc9f..9c567cf127e2e6ec7f326c71a26296b0847a9f06 100644
--- a/pkg/http/test/http_test.dart
+++ b/pkg/http/test/http_test.dart
@@ -12,180 +12,201 @@ import 'utils.dart';
main() {
group('http.', () {
- setUp(startServer);
tearDown(stopServer);
test('head', () {
- expect(http.head(serverUrl).then((response) {
- expect(response.statusCode, equals(200));
- expect(response.body, equals(''));
+ expect(startServer().then((_) {
+ expect(http.head(serverUrl).then((response) {
+ expect(response.statusCode, equals(200));
+ expect(response.body, equals(''));
+ }), completes);
}), completes);
});
test('get', () {
- expect(http.get(serverUrl, headers: {
- 'X-Random-Header': 'Value',
- 'X-Other-Header': 'Other Value'
- }).then((response) {
- expect(response.statusCode, equals(200));
- expect(response.body, parse(equals({
- 'method': 'GET',
- 'path': '/',
- 'headers': {
- 'content-length': ['0'],
- 'x-random-header': ['Value'],
- 'x-other-header': ['Other Value']
- },
- })));
+ expect(startServer().then((_) {
+ expect(http.get(serverUrl, headers: {
+ 'X-Random-Header': 'Value',
+ 'X-Other-Header': 'Other Value'
+ }).then((response) {
+ expect(response.statusCode, equals(200));
+ expect(response.body, parse(equals({
+ 'method': 'GET',
+ 'path': '/',
+ 'headers': {
+ 'content-length': ['0'],
+ 'x-random-header': ['Value'],
+ 'x-other-header': ['Other Value']
+ },
+ })));
+ }), completes);
}), completes);
});
test('post', () {
- expect(http.post(serverUrl, headers: {
- 'X-Random-Header': 'Value',
- 'X-Other-Header': 'Other Value'
- }, fields: {
- 'some-field': 'value',
- 'other-field': 'other value'
- }).then((response) {
- expect(response.statusCode, equals(200));
- expect(response.body, parse(equals({
- 'method': 'POST',
- 'path': '/',
- 'headers': {
- 'content-type': [
- 'application/x-www-form-urlencoded; charset=UTF-8'
- ],
- 'content-length': ['40'],
- 'x-random-header': ['Value'],
- 'x-other-header': ['Other Value']
- },
- 'body': 'some-field=value&other-field=other+value'
- })));
+ expect(startServer().then((_) {
+ expect(http.post(serverUrl, headers: {
+ 'X-Random-Header': 'Value',
+ 'X-Other-Header': 'Other Value'
+ }, fields: {
+ 'some-field': 'value',
+ 'other-field': 'other value'
+ }).then((response) {
+ expect(response.statusCode, equals(200));
+ expect(response.body, parse(equals({
+ 'method': 'POST',
+ 'path': '/',
+ 'headers': {
+ 'content-type': [
+ 'application/x-www-form-urlencoded; charset=UTF-8'
+ ],
+ 'content-length': ['40'],
+ 'x-random-header': ['Value'],
+ 'x-other-header': ['Other Value']
+ },
+ 'body': 'some-field=value&other-field=other+value'
+ })));
+ }), completes);
}), completes);
});
test('post without fields', () {
- expect(http.post(serverUrl, headers: {
- 'X-Random-Header': 'Value',
- 'X-Other-Header': 'Other Value',
- 'Content-Type': 'text/plain'
- }).then((response) {
- expect(response.statusCode, equals(200));
- expect(response.body, parse(equals({
- 'method': 'POST',
- 'path': '/',
- 'headers': {
- 'content-length': ['0'],
- 'content-type': ['text/plain'],
- 'x-random-header': ['Value'],
- 'x-other-header': ['Other Value']
- }
- })));
+ expect(startServer().then((_) {
+ expect(http.post(serverUrl, headers: {
+ 'X-Random-Header': 'Value',
+ 'X-Other-Header': 'Other Value',
+ 'Content-Type': 'text/plain'
+ }).then((response) {
+ expect(response.statusCode, equals(200));
+ expect(response.body, parse(equals({
+ 'method': 'POST',
+ 'path': '/',
+ 'headers': {
+ 'content-length': ['0'],
+ 'content-type': ['text/plain'],
+ 'x-random-header': ['Value'],
+ 'x-other-header': ['Other Value']
+ }
+ })));
+ }), completes);
}), completes);
});
test('put', () {
- expect(http.put(serverUrl, headers: {
- 'X-Random-Header': 'Value',
- 'X-Other-Header': 'Other Value'
- }, fields: {
- 'some-field': 'value',
- 'other-field': 'other value'
- }).then((response) {
- expect(response.statusCode, equals(200));
- expect(response.body, parse(equals({
- 'method': 'PUT',
- 'path': '/',
- 'headers': {
- 'content-type': [
- 'application/x-www-form-urlencoded; charset=UTF-8'
- ],
- 'content-length': ['40'],
- 'x-random-header': ['Value'],
- 'x-other-header': ['Other Value']
- },
- 'body': 'some-field=value&other-field=other+value'
- })));
+ expect(startServer().then((_) {
+ expect(http.put(serverUrl, headers: {
+ 'X-Random-Header': 'Value',
+ 'X-Other-Header': 'Other Value'
+ }, fields: {
+ 'some-field': 'value',
+ 'other-field': 'other value'
+ }).then((response) {
+ expect(response.statusCode, equals(200));
+ expect(response.body, parse(equals({
+ 'method': 'PUT',
+ 'path': '/',
+ 'headers': {
+ 'content-type': [
+ 'application/x-www-form-urlencoded; charset=UTF-8'
+ ],
+ 'content-length': ['40'],
+ 'x-random-header': ['Value'],
+ 'x-other-header': ['Other Value']
+ },
+ 'body': 'some-field=value&other-field=other+value'
+ })));
+ }), completes);
}), completes);
});
test('put without fields', () {
- expect(http.put(serverUrl, headers: {
- 'X-Random-Header': 'Value',
- 'X-Other-Header': 'Other Value',
- 'Content-Type': 'text/plain'
- }).then((response) {
- expect(response.statusCode, equals(200));
- expect(response.body, parse(equals({
- 'method': 'PUT',
- 'path': '/',
- 'headers': {
- 'content-length': ['0'],
- 'content-type': ['text/plain'],
- 'x-random-header': ['Value'],
- 'x-other-header': ['Other Value']
- }
- })));
+ expect(startServer().then((_) {
+ expect(http.put(serverUrl, headers: {
+ 'X-Random-Header': 'Value',
+ 'X-Other-Header': 'Other Value',
+ 'Content-Type': 'text/plain'
+ }).then((response) {
+ expect(response.statusCode, equals(200));
+ expect(response.body, parse(equals({
+ 'method': 'PUT',
+ 'path': '/',
+ 'headers': {
+ 'content-length': ['0'],
+ 'content-type': ['text/plain'],
+ 'x-random-header': ['Value'],
+ 'x-other-header': ['Other Value']
+ }
+ })));
+ }), completes);
}), completes);
});
test('delete', () {
- expect(http.delete(serverUrl, headers: {
- 'X-Random-Header': 'Value',
- 'X-Other-Header': 'Other Value'
- }).then((response) {
- expect(response.statusCode, equals(200));
- expect(response.body, parse(equals({
- 'method': 'DELETE',
+ expect(startServer().then((_) {
+ expect(http.delete(serverUrl, headers: {
+ 'X-Random-Header': 'Value',
+ 'X-Other-Header': 'Other Value'
+ }).then((response) {
+ expect(response.statusCode, equals(200));
+ expect(response.body, parse(equals({
+ 'method': 'DELETE',
+ 'path': '/',
+ 'headers': {
+ 'content-length': ['0'],
+ 'x-random-header': ['Value'],
+ 'x-other-header': ['Other Value']
+ }
+ })));
+ }), completes);
+ }), completes);
+ });
+
+ test('read', () {
+ expect(startServer().then((_) {
+ expect(http.read(serverUrl, headers: {
+ 'X-Random-Header': 'Value',
+ 'X-Other-Header': 'Other Value'
+ }).then((val) => val), completion(parse(equals({
+ 'method': 'GET',
'path': '/',
'headers': {
'content-length': ['0'],
'x-random-header': ['Value'],
'x-other-header': ['Other Value']
- }
- })));
+ },
+ }))));
}), completes);
});
- test('read', () {
- expect(http.read(serverUrl, headers: {
- 'X-Random-Header': 'Value',
- 'X-Other-Header': 'Other Value'
- }).then((val) => val), completion(parse(equals({
- 'method': 'GET',
- 'path': '/',
- 'headers': {
- 'content-length': ['0'],
- 'x-random-header': ['Value'],
- 'x-other-header': ['Other Value']
- },
- }))));
- });
-
test('read throws an error for a 4** status code', () {
- expect(http.read(serverUrl.resolve('/error')), throwsHttpException);
+ expect(startServer().then((_) {
+ expect(http.read(serverUrl.resolve('/error')), throwsHttpException);
+ }), completes);
});
test('readBytes', () {
- var future = http.readBytes(serverUrl, headers: {
- 'X-Random-Header': 'Value',
- 'X-Other-Header': 'Other Value'
- }).then((bytes) => new String.fromCharCodes(bytes));
-
- expect(future, completion(parse(equals({
- 'method': 'GET',
- 'path': '/',
- 'headers': {
- 'content-length': ['0'],
- 'x-random-header': ['Value'],
- 'x-other-header': ['Other Value']
- },
- }))));
+ expect(startServer().then((_) {
+ var future = http.readBytes(serverUrl, headers: {
+ 'X-Random-Header': 'Value',
+ 'X-Other-Header': 'Other Value'
+ }).then((bytes) => new String.fromCharCodes(bytes));
+
+ expect(future, completion(parse(equals({
+ 'method': 'GET',
+ 'path': '/',
+ 'headers': {
+ 'content-length': ['0'],
+ 'x-random-header': ['Value'],
+ 'x-other-header': ['Other Value']
+ },
+ }))));
+ }), completes);
});
test('readBytes throws an error for a 4** status code', () {
- expect(http.readBytes(serverUrl.resolve('/error')), throwsHttpException);
+ expect(startServer().then((_) {
+ expect(http.readBytes(serverUrl.resolve('/error')), throwsHttpException);
+ }), completes);
});
});
}
« 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