From bd2c6ddb9356796a3395b285acd399bb6c760704 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Fri, 22 Dec 2017 08:35:46 -0500 Subject: [PATCH] Upgrade tests to 1.1.0 --- test/hooks_test.dart | 18 ++++++++++-------- test/permission_test.dart | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/test/hooks_test.dart b/test/hooks_test.dart index 3c158e91..b9fdebe0 100644 --- a/test/hooks_test.dart +++ b/test/hooks_test.dart @@ -12,7 +12,7 @@ main() { setUp(() async { app = new Angel() ..lazyParseBodies = true - ..before.add((RequestContext req, res) async { + ..use((RequestContext req, res) async { var xUser = req.headers.value('X-User'); if (xUser != null) req.inject('user', @@ -25,7 +25,7 @@ main() { ..use('/artists', new ArtistService()) ..use('/roled', new RoledService()); - app.service('user_data') + (app.service('user_data') as HookedService) ..beforeIndexed.listen(hooks.queryWithCurrentUser()) ..beforeCreated.listen(hooks.hashPassword()); @@ -34,14 +34,16 @@ main() { ..beforeRead.listen(hooks.restrictToOwner()) ..beforeCreated.listen(hooks.associateCurrentUser()); - app.service('roled') + (app.service('roled') as HookedService) ..beforeIndexed.listen(new Permission('foo:*').toHook()) ..beforeRead.listen(new Permission('foo:*').toHook(owner: true)); - app.fatalErrorStream.listen((e) { - print('Fatal: ${e.error}'); - print(e.stack); - }); + var errorHandler = app.errorHandler; + app.errorHandler = (e, req, res) { + print(e.toJson()); + print(e.stackTrace); + return errorHandler(e, req, res); + }; client = await connectTo(app); }); @@ -272,7 +274,7 @@ const Artist _MICHAEL_JACKSON = class RoledService extends Service { @override - index([params]) { + index([params]) async { return ['foo']; } diff --git a/test/permission_test.dart b/test/permission_test.dart index 86359e2b..139aa70a 100644 --- a/test/permission_test.dart +++ b/test/permission_test.dart @@ -16,7 +16,7 @@ main() { setUp(() async { app = new Angel(); - app.before.add((RequestContext req, res) async { + app.use((RequestContext req, res) async { // In real life, you'd use auth to check user roles, // but in this case, let's just set the user manually var xRoles = req.headers.value('X-Roles');