on master help sign in
Clean up the comments
commit0d0fd0de82d099e6f0c87c73398fb3036e38172f authorErik Aker <eraker@gmail.com> dateSat 13 Oct 2018, 06:35 (8 years ago) parent18456ba
1 file changed+4−3
doc/cookbook/testing/Testing.lhs+4−3
doc/cookbook/testing/Testing.lhs+4−3
@@ -267,10 +267,12 @@ esTestApp = serve (Proxy :: Proxy SearchAPI) esTestServer
267267esTestServer :: Server SearchAPI
268268esTestServer = getESDocument
269269
270+-- This is the *mock* handler we're going to use. We create it
271+-- here specifically to trigger different behavior in our tests.
270272getESDocument :: Integer -> Handler Value
271273getESDocument docId
272− -- arbitrary things we can trigger in our tests to check for failure
273− -- We want to try to trigger different code paths
274+ -- arbitrary things we can use in our tests to simulate failure
275+ -- We want to trigger different code paths
274276 | docId > 1000 = throwError err500
275277 | docId > 500 = pure . Object $ HM.fromList [("bad", String "data")]
276278 | otherwise = pure $ Object $ HM.fromList [("_source", Object $ HM.fromList [("a", String "b")])]
@@ -294,7 +296,6 @@ thirdPartyResourcesSpec = around_ withElasticsearch $ do
294296 -- `get` is a function from hspec-wai`.
295297 get "/docs/1" `shouldRespondWith` 200
296298 it "should be able to handle connection failures" $
297− -- We can also make custom HTTP requests with the `request` function
298299 get "/docs/1001" `shouldRespondWith` 404
299300 it "should be able to handle parsing failures" $
300301 get "/docs/501" `shouldRespondWith` 400