git.iko.soy/typeable/servant
on master help sign in
Pull out instance for hopefully more clarity
commitbb365159f3efbc125d052b1828f87c2faa3d5a85 authorErik Aker <eraker@gmail.com> dateSun 14 Oct 2018, 13:27 (8 years ago) parent02da07f
1 file changed+4−1
doc/cookbook/testing/Testing.lhs+4−1
doc/cookbook/testing/Testing.lhs+4−1
@@ -253,6 +253,9 @@ Imagine, then, that this is our real server implementation:
253253type DocApi =
254254 "docs" :> Capture "docId" Integer :> Get '[JSON] Value
255255
256+docsApp :: Text -> Text -> Application
257+docsApp esHost esPort = serve (Proxy :: Proxy DocApi) $ docServer esHost esPort
258+
256259docServer :: Text -> Text -> Server DocApi
257260docServer esHost esPort = getDocById esHost esPort
258261
@@ -330,7 +333,7 @@ Hopefully, this will simplify our testing code:
330333thirdPartyResourcesSpec :: Spec
331334thirdPartyResourcesSpec = around_ withElasticsearch $ do
332335 -- we call `with` from `hspec-wai` and pass *real* `Application`
333− with (pure $ serve (Proxy :: Proxy DocApi) $ docServer "localhost" "9999") $ do
336+ with (pure $ docsApp "localhost" "9999") $ do
334337 describe "GET /docs" $ do
335338 it "should be able to get a document" $
336339 -- `get` is a function from hspec-wai`.