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

Side by Side Diff: pkg/json_rpc_2/test/server/utils.dart

Issue 224903010: Pass RpcException error data through if it's not a map. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. 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/json_rpc_2/test/server/server_test.dart ('k') | no next file » | 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 json_rpc_2.test.server.util; 5 library json_rpc_2.test.server.util;
6 6
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'package:json_rpc_2/json_rpc_2.dart' as json_rpc; 8 import 'package:json_rpc_2/json_rpc_2.dart' as json_rpc;
9 9
10 void expectErrorResponse(json_rpc.Server server, request, int errorCode, 10 void expectErrorResponse(json_rpc.Server server, request, int errorCode,
11 String message) { 11 String message, {data}) {
12 var id; 12 var id;
13 if (request is Map) id = request['id']; 13 if (request is Map) id = request['id'];
14 if (data == null) data = {'request': request};
14 15
15 expect(server.handleRequest(request), completion(equals({ 16 expect(server.handleRequest(request), completion(equals({
16 'jsonrpc': '2.0', 17 'jsonrpc': '2.0',
17 'id': id, 18 'id': id,
18 'error': { 19 'error': {
19 'code': errorCode, 20 'code': errorCode,
20 'message': message, 21 'message': message,
21 'data': {'request': request} 22 'data': data
22 } 23 }
23 }))); 24 })));
24 } 25 }
25 26
26 Matcher throwsInvalidParams(String message) { 27 Matcher throwsInvalidParams(String message) {
27 return throwsA(predicate((error) { 28 return throwsA(predicate((error) {
28 expect(error, new isInstanceOf<json_rpc.RpcException>()); 29 expect(error, new isInstanceOf<json_rpc.RpcException>());
29 expect(error.message, equals(message)); 30 expect(error.message, equals(message));
30 return true; 31 return true;
31 })); 32 }));
32 } 33 }
OLDNEW
« no previous file with comments | « pkg/json_rpc_2/test/server/server_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698