OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library shelf.log_middleware_test; | 5 library shelf.log_middleware_test; |
6 | 6 |
7 import 'package:shelf/shelf.dart'; | 7 import 'package:shelf/shelf.dart'; |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 | 9 |
10 import 'test_util.dart'; | 10 import 'test_util.dart'; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 gotLog = true; | 51 gotLog = true; |
52 expect(isError, isTrue); | 52 expect(isError, isTrue); |
53 expect(msg, contains('\tGET\t/')); | 53 expect(msg, contains('\tGET\t/')); |
54 expect(msg, contains('testing logging throw')); | 54 expect(msg, contains('testing logging throw')); |
55 })).addHandler((request) { | 55 })).addHandler((request) { |
56 throw 'testing logging throw'; | 56 throw 'testing logging throw'; |
57 }); | 57 }); |
58 | 58 |
59 expect(makeSimpleRequest(handler), throwsA('testing logging throw')); | 59 expect(makeSimpleRequest(handler), throwsA('testing logging throw')); |
60 }); | 60 }); |
| 61 |
| 62 test("doesn't log a HijackException", () { |
| 63 var handler = const Pipeline() |
| 64 .addMiddleware(logRequests(logger: logger)) |
| 65 .addHandler((request) => throw const HijackException()); |
| 66 |
| 67 expect(makeSimpleRequest(handler).whenComplete(() { |
| 68 expect(gotLog, isFalse); |
| 69 }), throwsA(new isInstanceOf<HijackException>())); |
| 70 }); |
61 } | 71 } |
OLD | NEW |