mirror of
https://github.com/codex-storage/nim-json-rpc.git
synced 2025-02-24 00:48:12 +00:00
Updated tests to check return type processing
This commit is contained in:
parent
7355543147
commit
2c8faae0b5
@ -57,6 +57,13 @@ s.on("rpc.seqparam") do(a: string, s: seq[int]):
|
|||||||
s.on("rpc.objparam") do(a: string, obj: MyObject):
|
s.on("rpc.objparam") do(a: string, obj: MyObject):
|
||||||
result = %obj
|
result = %obj
|
||||||
|
|
||||||
|
s.on("rpc.returntypesimple") do(i: int) -> int:
|
||||||
|
result = i
|
||||||
|
|
||||||
|
s.on("rpc.returntypecomplex") do(i: int) -> Test2:
|
||||||
|
result.x = [1, i, 3]
|
||||||
|
result.y = "test"
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
suite "Server types":
|
suite "Server types":
|
||||||
|
|
||||||
@ -81,6 +88,18 @@ suite "Server types":
|
|||||||
let r = waitfor rpcObjParam(%[%"abc", testObj])
|
let r = waitfor rpcObjParam(%[%"abc", testObj])
|
||||||
check r == testObj
|
check r == testObj
|
||||||
|
|
||||||
|
test "Simple return types":
|
||||||
|
let
|
||||||
|
inp = %99
|
||||||
|
r1 = waitfor rpcReturnTypeSimple(%[%inp])
|
||||||
|
check r1 == inp
|
||||||
|
|
||||||
|
test "Complex return types":
|
||||||
|
let
|
||||||
|
inp = 99
|
||||||
|
r1 = waitfor rpcReturnTypeComplex(%[%inp])
|
||||||
|
check r1 == %*{"x": %[1, inp, 3], "y": "test"}
|
||||||
|
|
||||||
test "Runtime errors":
|
test "Runtime errors":
|
||||||
expect ValueError:
|
expect ValueError:
|
||||||
discard waitfor rpcArrayParam(%[%[0, 1, 2, 3, 4, 5, 6], %"hello"])
|
discard waitfor rpcArrayParam(%[%[0, 1, 2, 3, 4, 5, 6], %"hello"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user