1
0
Fork 0

- [JSON-RPC] fixed tests (the error object returns the field 'data' now).

This commit is contained in:
cage 2023-01-13 14:59:36 +01:00
parent 37af6fef04
commit 5ce7e5c082
1 changed files with 10 additions and 10 deletions

View File

@ -95,7 +95,7 @@
"{\"jsonrpc\":\"2.0\",\"method\":\"foobar\",\"id\":1}" "{\"jsonrpc\":\"2.0\",\"method\":\"foobar\",\"id\":1}"
(strcat "{\"jsonrpc\":\"2.0\"," (strcat "{\"jsonrpc\":\"2.0\","
"\"error\":{\"code\":-32601," "\"error\":{\"code\":-32601,"
"\"message\":\"Method not found: \\\"foobar\\\"\"},\"id\":1}"))) "\"message\":\"Method not found: \\\"foobar\\\"\",\"data\":null},\"id\":1}")))
(deftest test-invalid-json (json-rpc2-suite) (deftest test-invalid-json (json-rpc2-suite)
(let* ((json-req "{\"jsonrpc\": \"2.0\", \"method\": \"foobar, \"params\": \"bar\", \"baz]") (let* ((json-req "{\"jsonrpc\": \"2.0\", \"method\": \"foobar, \"params\": \"bar\", \"baz]")
@ -103,7 +103,7 @@
(assert-true (assert-true
(string= json-resp (string= json-resp
(strcat "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32700," (strcat "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32700,"
"\"message\":\"Parse error\"},\"id\":null}"))))) "\"message\":\"Parse error\",\"data\":null},\"id\":null}")))))
(deftest test-invalid-request (json-rpc2-suite) (deftest test-invalid-request (json-rpc2-suite)
(let* ((json-req "{\"jsonrpc\": \"2.0\", \"method\": 1, \"params\": \"bar\"}") (let* ((json-req "{\"jsonrpc\": \"2.0\", \"method\": 1, \"params\": \"bar\"}")
@ -111,7 +111,7 @@
(assert-true (assert-true
(string= json-resp (string= json-resp
(strcat "{\"jsonrpc\":\"2.0\",\"error\":" (strcat "{\"jsonrpc\":\"2.0\",\"error\":"
"{\"code\":-32600,\"message\":\"Invalid Request\"},\"id\":null}"))))) "{\"code\":-32600,\"message\":\"Invalid Request\",\"data\":null},\"id\":null}")))))
(deftest test-batch (json-rpc2-suite) (deftest test-batch (json-rpc2-suite)
(prepare-rpc (prepare-rpc
@ -124,7 +124,7 @@
(expected (strcat "[" (expected (strcat "["
"{\"jsonrpc\":\"2.0\",\"result\":30,\"id\":2}," "{\"jsonrpc\":\"2.0\",\"result\":30,\"id\":2},"
"{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32601," "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32601,"
"\"message\":\"Method not found: \\\"foo\\\"\"},\"id\":1}," "\"message\":\"Method not found: \\\"foo\\\"\",\"data\":null},\"id\":1},"
"{\"jsonrpc\":\"2.0\",\"result\":3,\"id\":1}" "{\"jsonrpc\":\"2.0\",\"result\":3,\"id\":1}"
"]"))) "]")))
(assert-equality #'string= (assert-equality #'string=
@ -141,7 +141,7 @@
(assert-true (assert-true
(string= json-resp (string= json-resp
(strcat "{\"jsonrpc\":\"2.0\",\"error\":" (strcat "{\"jsonrpc\":\"2.0\",\"error\":"
"{\"code\":-32700,\"message\":\"Parse error\"},\"id\":null}"))))) "{\"code\":-32700,\"message\":\"Parse error\",\"data\":null},\"id\":null}")))))
(deftest test-batch-empty-array (json-rpc2-suite) (deftest test-batch-empty-array (json-rpc2-suite)
(let* ((json-req "[]") (let* ((json-req "[]")
@ -149,7 +149,7 @@
(assert-true (assert-true
(string= json-resp (string= json-resp
(strcat "{\"jsonrpc\":\"2.0\",\"error\":" (strcat "{\"jsonrpc\":\"2.0\",\"error\":"
"{\"code\":-32600,\"message\":\"Invalid Request\"},\"id\":null}"))))) "{\"code\":-32600,\"message\":\"Invalid Request\",\"data\":null},\"id\":null}")))))
(deftest test-batch-invalid (json-rpc2-suite) (deftest test-batch-invalid (json-rpc2-suite)
(let* ((json-req "[1]") (let* ((json-req "[1]")
@ -158,7 +158,7 @@
(string= json-resp (string= json-resp
(strcat "[" (strcat "["
"{\"jsonrpc\":\"2.0\",\"error\":" "{\"jsonrpc\":\"2.0\",\"error\":"
"{\"code\":-32600,\"message\":\"Invalid Request\"},\"id\":null}" "{\"code\":-32600,\"message\":\"Invalid Request\",\"data\":null},\"id\":null}"
"]"))))) "]")))))
(deftest test-batch-invalid-2 (json-rpc2-suite) (deftest test-batch-invalid-2 (json-rpc2-suite)
@ -168,11 +168,11 @@
(string= json-resp (string= json-resp
(strcat "[" (strcat "["
"{\"jsonrpc\":\"2.0\",\"error\":" "{\"jsonrpc\":\"2.0\",\"error\":"
"{\"code\":-32600,\"message\":\"Invalid Request\"},\"id\":null}," "{\"code\":-32600,\"message\":\"Invalid Request\",\"data\":null},\"id\":null},"
"{\"jsonrpc\":\"2.0\",\"error\":" "{\"jsonrpc\":\"2.0\",\"error\":"
"{\"code\":-32600,\"message\":\"Invalid Request\"},\"id\":null}," "{\"code\":-32600,\"message\":\"Invalid Request\",\"data\":null},\"id\":null},"
"{\"jsonrpc\":\"2.0\",\"error\":{\"code\":" "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":"
"-32600,\"message\":\"Invalid Request\"},\"id\":null}" "-32600,\"message\":\"Invalid Request\",\"data\":null},\"id\":null}"
"]"))))) "]")))))
(deftest test-batch-notification (json-rpc2-suite) (deftest test-batch-notification (json-rpc2-suite)