Fix a broken oauth2 test.
TBR
Review URL: https://codereview.chromium.org//14694002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22203 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/src/client.dart b/lib/src/client.dart
index 62a06ca..62e2288 100644
--- a/lib/src/client.dart
+++ b/lib/src/client.dart
@@ -110,7 +110,7 @@
throw new AuthorizationException(
params['error'], params['error_description'],
- Uri.parse(params['error_uri']));
+ params['error_uri'] == null ? null : Uri.parse(params['error_uri']));
});
}
diff --git a/test/client_test.dart b/test/client_test.dart
index bac0548..7a05e99 100644
--- a/test/client_test.dart
+++ b/test/client_test.dart
@@ -25,12 +25,6 @@
httpClient = new ExpectClient();
}
-void expectFutureThrows(future, predicate) {
- future.catchError(expectAsync1((error) {
- expect(predicate(error), isTrue);
- }));
-}
-
void main() {
group('with expired credentials', () {
setUp(createHttpClient);
@@ -42,8 +36,8 @@
var client = new oauth2.Client('identifier', 'secret', credentials,
httpClient: httpClient);
- expectFutureThrows(client.get(requestUri),
- (e) => e is oauth2.ExpirationException);
+ expect(client.get(requestUri),
+ throwsA(new isInstanceOf<oauth2.ExpirationException>()));
});
test("that can be refreshed refreshes the credentials and sends the "
@@ -123,8 +117,7 @@
var client = new oauth2.Client('identifier', 'secret', credentials,
httpClient: httpClient);
- expectFutureThrows(client.refreshCredentials(),
- (e) => e is StateError);
+ expect(client.refreshCredentials(), throwsA(isStateError));
});
});
@@ -148,8 +141,8 @@
headers: {'www-authenticate': authenticate}));
});
- expectFutureThrows(client.read(requestUri),
- (e) => e is oauth2.AuthorizationException);
+ expect(client.read(requestUri),
+ throwsA(new isInstanceOf<oauth2.AuthorizationException>()));
});
test('passes through a 401 response without www-authenticate', () {