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 json_rpc_2.test.server.parameters_test; | 5 library json_rpc_2.test.server.parameters_test; |
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 import 'utils.dart'; | 10 import 'utils.dart'; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 test("[].asUri fails for non-URI parameters", () { | 255 test("[].asUri fails for non-URI parameters", () { |
256 expect(() => parameters['int'].asUri, | 256 expect(() => parameters['int'].asUri, |
257 throwsInvalidParams('Parameter "int" for method "foo" must be a ' | 257 throwsInvalidParams('Parameter "int" for method "foo" must be a ' |
258 'string, but was 1.')); | 258 'string, but was 1.')); |
259 }); | 259 }); |
260 | 260 |
261 test("[].asUri fails for invalid URIs", () { | 261 test("[].asUri fails for invalid URIs", () { |
262 expect(() => parameters['invalid-uri'].asUri, | 262 expect(() => parameters['invalid-uri'].asUri, |
263 throwsInvalidParams('Parameter "invalid-uri" for method "foo" must ' | 263 throwsInvalidParams('Parameter "invalid-uri" for method "foo" must ' |
264 'be a valid URI, but was "http://[::1".\n' | 264 'be a valid URI, but was "http://[::1".\n' |
265 'Bad end of IPv6 host')); | 265 'Missing end `]` to match `[` in host at position 7.\n' |
| 266 'http://[::1\n' |
| 267 ' ^')); |
266 }); | 268 }); |
267 | 269 |
268 group("with a nested parameter map", () { | 270 group("with a nested parameter map", () { |
269 var nested; | 271 var nested; |
270 setUp(() => nested = parameters['map']); | 272 setUp(() => nested = parameters['map']); |
271 | 273 |
272 test("[int] fails with a type error", () { | 274 test("[int] fails with a type error", () { |
273 expect(() => nested[0], | 275 expect(() => nested[0], |
274 throwsInvalidParams('Parameter "map" for method "foo" must be an ' | 276 throwsInvalidParams('Parameter "map" for method "foo" must be an ' |
275 'Array, but was {"num":4.2,"bool":false}.')); | 277 'Array, but was {"num":4.2,"bool":false}.')); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 test("with a complex parameter path", () { | 368 test("with a complex parameter path", () { |
367 var parameters = new json_rpc.Parameters("foo", { | 369 var parameters = new json_rpc.Parameters("foo", { |
368 'bar baz': [0, 1, 2, {'bang.zap': {'\n': 'qux'}}] | 370 'bar baz': [0, 1, 2, {'bang.zap': {'\n': 'qux'}}] |
369 }); | 371 }); |
370 | 372 |
371 expect(() => parameters['bar baz'][3]['bang.zap']['\n']['bip'], | 373 expect(() => parameters['bar baz'][3]['bang.zap']['\n']['bip'], |
372 throwsInvalidParams('Parameter "bar baz"[3]."bang.zap"."\\n" for ' | 374 throwsInvalidParams('Parameter "bar baz"[3]."bang.zap"."\\n" for ' |
373 'method "foo" must be an Object, but was "qux".')); | 375 'method "foo" must be an Object, but was "qux".')); |
374 }); | 376 }); |
375 } | 377 } |
OLD | NEW |