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

Side by Side Diff: pkg/shelf/test/log_middleware_test.dart

Issue 238813003: pkg/shelf: rename Stack to Pipeline (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nit Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/shelf/test/create_middleware_test.dart ('k') | pkg/shelf/test/pipeline_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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';
11 11
12 void main() { 12 void main() {
13 bool gotLog; 13 bool gotLog;
14 14
15 setUp(() { 15 setUp(() {
16 gotLog = false; 16 gotLog = false;
17 }); 17 });
18 18
19 var logger = (msg, isError) { 19 var logger = (msg, isError) {
20 expect(gotLog, isFalse); 20 expect(gotLog, isFalse);
21 gotLog = true; 21 gotLog = true;
22 expect(isError, isFalse); 22 expect(isError, isFalse);
23 expect(msg, contains('GET')); 23 expect(msg, contains('GET'));
24 expect(msg, contains('[200]')); 24 expect(msg, contains('[200]'));
25 }; 25 };
26 26
27 test('logs a request with a synchronous response', () { 27 test('logs a request with a synchronous response', () {
28 var handler = const Stack() 28 var handler = const Pipeline()
29 .addMiddleware(logRequests(logger: logger)) 29 .addMiddleware(logRequests(logger: logger))
30 .addHandler(syncHandler); 30 .addHandler(syncHandler);
31 31
32 return makeSimpleRequest(handler).then((response) { 32 return makeSimpleRequest(handler).then((response) {
33 expect(gotLog, isTrue); 33 expect(gotLog, isTrue);
34 }); 34 });
35 }); 35 });
36 36
37 test('logs a request with an asynchronous response', () { 37 test('logs a request with an asynchronous response', () {
38 var handler = const Stack() 38 var handler = const Pipeline()
39 .addMiddleware(logRequests(logger: logger)) 39 .addMiddleware(logRequests(logger: logger))
40 .addHandler(asyncHandler); 40 .addHandler(asyncHandler);
41 41
42 return makeSimpleRequest(handler).then((response) { 42 return makeSimpleRequest(handler).then((response) {
43 expect(gotLog, isTrue); 43 expect(gotLog, isTrue);
44 }); 44 });
45 }); 45 });
46 46
47 test('logs a request with an asynchronous response', () { 47 test('logs a request with an asynchronous response', () {
48 var handler = const Stack() 48 var handler = const Pipeline()
49 .addMiddleware(logRequests(logger: (msg, isError) { 49 .addMiddleware(logRequests(logger: (msg, isError) {
50 expect(gotLog, isFalse); 50 expect(gotLog, isFalse);
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 } 61 }
OLDNEW
« no previous file with comments | « pkg/shelf/test/create_middleware_test.dart ('k') | pkg/shelf/test/pipeline_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698