mirror of
https://github.com/status-im/nim-json-rpc.git
synced 2025-02-24 18:28:10 +00:00
Updated tests to check return type processing
This commit is contained in:
parent
31c9ca9196
commit
444bbc1493
@ -57,6 +57,13 @@ s.on("rpc.seqparam") do(a: string, s: seq[int]):
|
||||
s.on("rpc.objparam") do(a: string, obj: MyObject):
|
||||
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
|
||||
suite "Server types":
|
||||
|
||||
@ -81,6 +88,18 @@ suite "Server types":
|
||||
let r = waitfor rpcObjParam(%[%"abc", 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":
|
||||
expect ValueError:
|
||||
discard waitfor rpcArrayParam(%[%[0, 1, 2, 3, 4, 5, 6], %"hello"])
|
||||
|
Loading…
x
Reference in New Issue
Block a user