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

Unified Diff: pkg/scheduled_test/test/scheduled_server_test.dart

Issue 23591061: Make package:scheduled_test throw ScheduledServerErrors, not strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix formatting and stray code. Created 7 years, 3 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
Index: pkg/scheduled_test/test/scheduled_server_test.dart
diff --git a/pkg/scheduled_test/test/scheduled_server_test.dart b/pkg/scheduled_test/test/scheduled_server_test.dart
index b4cd897eb666c5137f069336b75d56c6d67c0b06..5c0121c78a612ebae937e9cac8e3f7fcd8ea6fb3 100644
--- a/pkg/scheduled_test/test/scheduled_server_test.dart
+++ b/pkg/scheduled_test/test/scheduled_server_test.dart
@@ -37,18 +37,11 @@ void main() {
test('test 2', () {
expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
- // TODO(nweiz): There can be three errors due to issue 9151. The
- // HttpException is reported without a stack trace, and so when it's
- // wrapped twice it registers as a different exception each time (because
- // it's given an ad-hoc stack trace). Always expect two exceptions when
- // issue 9151 is fixed.
- expect(errors.length, inInclusiveRange(2, 3));
- expect(errors[0].error, equals("'scheduled server 0' received GET /hello "
- "when no more requests were expected."));
+ expect(errors.length, 2);
+ expect(errors[0].error, new isInstanceOf<ScheduledServerError>());
+ expect(errors[0].error.message, equals("'scheduled server 0' received "
+ "GET /hello when no more requests were expected."));
expect(errors[1].error, new isInstanceOf<HttpException>());
- if (errors.length > 2) {
- expect(errors[2].error, new isInstanceOf<HttpException>());
- }
});
}, passing: ['test 2']);
@@ -115,8 +108,9 @@ void main() {
// it's given an ad-hoc stack trace). Always expect two exceptions when
// issue 9151 is fixed.
expect(errors.length, inInclusiveRange(2, 3));
- expect(errors[0].error, equals("'scheduled server 0' received GET /hello "
- "earlier than expected."));
+ expect(errors[0].error, new isInstanceOf<ScheduledServerError>());
+ expect(errors[0].error.message, equals(
+ "'scheduled server 0' received GET /hello earlier than expected."));
expect(errors[1].error, new isInstanceOf<HttpException>());
if (errors.length > 2) {
expect(errors[2].error, new isInstanceOf<HttpException>());
@@ -165,18 +159,11 @@ void main() {
});
test('test 2', () {
- // TODO(nweiz): There can be three errors due to issue 9151. The
- // HttpException is reported without a stack trace, and so when it's
- // wrapped twice it registers as a different exception each time (because
- // it's given an ad-hoc stack trace). Always expect two exceptions when
- // issue 9151 is fixed.
- expect(errors.length, inInclusiveRange(2, 3));
- expect(errors[0].error, equals("'scheduled server 0' expected GET "
- "/goodbye, but got GET /hello."));
+ expect(errors.length, 2);
+ expect(errors[0].error, new isInstanceOf<ScheduledServerError>());
+ expect(errors[0].error.message, equals(
+ "'scheduled server 0' expected GET /goodbye, but got GET /hello."));
expect(errors[1].error, new isInstanceOf<HttpException>());
- if (errors.length > 2) {
- expect(errors[2].error, new isInstanceOf<HttpException>());
- }
});
}, passing: ['test 2']);
@@ -198,18 +185,11 @@ void main() {
});
test('test 2', () {
- // TODO(nweiz): There can be three errors due to issue 9151. The
- // HttpException is reported without a stack trace, and so when it's
- // wrapped twice it registers as a different exception each time (because
- // it's given an ad-hoc stack trace). Always expect two exceptions when
- // issue 9151 is fixed.
- expect(errors.length, inInclusiveRange(2, 3));
- expect(errors[0].error, equals("'scheduled server 0' expected GET "
- "/hello, but got HEAD /hello."));
+ expect(errors.length, 2);
+ expect(errors[0].error, new isInstanceOf<ScheduledServerError>());
+ expect(errors[0].error.message, equals(
+ "'scheduled server 0' expected GET /hello, but got HEAD /hello."));
expect(errors[1].error, new isInstanceOf<HttpException>());
- if (errors.length > 2) {
- expect(errors[2].error, new isInstanceOf<HttpException>());
- }
});
}, passing: ['test 2']);
@@ -303,18 +283,11 @@ void main() {
});
test('test 2', () {
- // TODO(nweiz): There can be three errors due to issue 9151. The
- // HttpException is reported without a stack trace, and so when it's
- // wrapped twice it registers as a different exception each time (because
- // it's given an ad-hoc stack trace). Always expect two exceptions when
- // issue 9151 is fixed.
- expect(errors.length, inInclusiveRange(2, 3));
- expect(errors[0].error, equals("'scheduled server 0' received GET "
- "/hello/3 when no more requests were expected."));
+ expect(errors.length, 2);
+ expect(errors[0].error, new isInstanceOf<ScheduledServerError>());
+ expect(errors[0].error.message, equals("'scheduled server 0' received "
+ "GET /hello/3 when no more requests were expected."));
expect(errors[1].error, new isInstanceOf<HttpException>());
- if (errors.length > 2) {
- expect(errors[2].error, new isInstanceOf<HttpException>());
- }
});
}, passing: ['test 2']);
@@ -330,22 +303,15 @@ void main() {
completion(equals('Hello, test!')));
server.handle('GET', '/hello', (request) {
- throw 'oh no';
+ throw new TestFailure('oh no');
});
});
test('test 2', () {
- // TODO(nweiz): There can be three errors due to issue 9151. The
- // HttpException is reported without a stack trace, and so when it's
- // wrapped twice it registers as a different exception each time (because
- // it's given an ad-hoc stack trace). Always expect two exceptions when
- // issue 9151 is fixed.
- expect(errors.length, inInclusiveRange(2, 3));
- expect(errors[0].error, equals('oh no'));
+ expect(errors.length, 2);
+ expect(errors[0].error, new isInstanceOf<TestFailure>());
+ expect(errors[0].error.message, equals('oh no'));
expect(errors[1].error, new isInstanceOf<HttpException>());
- if (errors.length > 2) {
- expect(errors[2].error, new isInstanceOf<HttpException>());
- }
});
}, passing: ['test 2']);
}

Powered by Google App Engine
This is Rietveld 408576698