From d65d011e5ec3669effec15bdd1f33431c288de61 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Sun, 16 Aug 2015 18:40:26 -0700 Subject: [PATCH] Tests for rpc --- test/Feature/QuerySpec.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/Feature/QuerySpec.hs b/test/Feature/QuerySpec.hs index e3f83c6e3..6256e195a 100644 --- a/test/Feature/QuerySpec.hs +++ b/test/Feature/QuerySpec.hs @@ -172,3 +172,15 @@ spec = [json| [{"data": {"foo": {"bar": "baz"}}}] |] get "/json?data->foo->>bar=eq.fake" `shouldRespondWith` [json| [] |] + + describe "remote procedure call" $ do + context "a proc that returns a set" . before_ (clearTable "items" >> createItems 10) . + after_ (clearTable "items") $ + it "returns proper json" $ + post "/rpc/getitemrange" [json| { "min": 2, "max": 4 } |] `shouldRespondWith` + [json| [ {"id": 3}, {"id":4} ] |] + + context "a proc that returns plain text" $ + it "returns proper json" $ + post "/rpc/sayhello" [json| { "name": "world" } |] `shouldRespondWith` + [json| [{"sayhello":"Hello, world"}] |]