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

Unified Diff: pkg/oauth2/test/client_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/oauth2/test/authorization_code_grant_test.dart ('k') | pkg/serialization/lib/src/mirrors_helpers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/oauth2/test/client_test.dart
diff --git a/pkg/oauth2/test/client_test.dart b/pkg/oauth2/test/client_test.dart
index af8e7e47440d5d939d37584789ae87477ffb7f41..6ad7e48b3c116359bc239f7b984c21e5548e0221 100644
--- a/pkg/oauth2/test/client_test.dart
+++ b/pkg/oauth2/test/client_test.dart
@@ -4,8 +4,9 @@
library client_test;
+import 'dart:async';
import 'dart:io';
-import 'dart:json';
+import 'dart:json' as JSON;
import 'dart:uri';
import '../../unittest/lib/unittest.dart';
@@ -23,6 +24,12 @@ void createHttpClient() {
httpClient = new ExpectClient();
}
+void expectFutureThrows(future, predicate) {
+ future.catchError(expectAsync1((AsyncError e) {
+ expect(predicate(e.error), isTrue);
+ }));
+}
+
void main() {
group('with expired credentials', () {
setUp(createHttpClient);
@@ -34,7 +41,8 @@ void main() {
var client = new oauth2.Client('identifier', 'secret', credentials,
httpClient: httpClient);
- expect(client.get(requestUri), throwsExpirationException);
+ expectFutureThrows(client.get(requestUri),
+ (e) => e is oauth2.ExpirationException);
});
test("that can be refreshed refreshes the credentials and sends the "
@@ -114,7 +122,8 @@ void main() {
var client = new oauth2.Client('identifier', 'secret', credentials,
httpClient: httpClient);
- expect(client.refreshCredentials(), throwsStateError);
+ expectFutureThrows(client.refreshCredentials(),
+ (e) => e is StateError);
});
});
@@ -138,7 +147,8 @@ void main() {
headers: {'www-authenticate': authenticate}));
});
- expect(client.read(requestUri), throwsAuthorizationException);
+ expectFutureThrows(client.read(requestUri),
+ (e) => e is oauth2.AuthorizationException);
});
test('passes through a 401 response without www-authenticate', () {
« no previous file with comments | « pkg/oauth2/test/authorization_code_grant_test.dart ('k') | pkg/serialization/lib/src/mirrors_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698