From 9b4854f516b30a60fce00ec6b40b62ce8fe0fb14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Hahn?= Date: Wed, 6 Apr 2016 18:32:18 +0800 Subject: [PATCH 1/2] remove comment --- src/Reserve.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Reserve.hs b/src/Reserve.hs index 99a1d65..25386e1 100644 --- a/src/Reserve.hs +++ b/src/Reserve.hs @@ -23,7 +23,6 @@ import qualified Interpreter data Session = Session Socket Interpreter openSession :: Options -> IO Session --- openSession opts = Session <$> listenOn (optionsReservePort opts) <*> Interpreter.new (optionsMainIs opts) openSession opts = Session <$> listenOn (PortNumber $ optionsReservePort opts) <*> Interpreter.new (optionsMainIs opts) closeSession :: Session -> IO () From befb3aba1b9823c8808beb92d0757f49cee274d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Hahn?= Date: Sat, 9 Apr 2016 12:58:51 +0800 Subject: [PATCH 2/2] change test port to 12001 so that it doesn't conflict with running reserve instances --- test/ReserveSpec.hs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/test/ReserveSpec.hs b/test/ReserveSpec.hs index 10976dc..651ecef 100644 --- a/test/ReserveSpec.hs +++ b/test/ReserveSpec.hs @@ -43,26 +43,30 @@ withServer action = inTempDirectory $ do bracket (runReserve mvar) killThread (const $ yield >> action) takeMVar mvar where - runReserve mvar = forkIO $ run defaultOptions {optionsMainIs = "app.hs"} `finally` putMVar mvar () + runReserve mvar = forkIO $ run options `finally` putMVar mvar () + options = defaultOptions { + optionsMainIs = "app.hs", + optionsReservePort = 12001 + } spec :: Spec spec = around_ withServer $ do describe "run" $ do it "runs app" $ do - simpleHttp "http://localhost:12000/" `shouldReturn` "hello" + simpleHttp "http://localhost:12001/" `shouldReturn` "hello" it "reloads app" $ do - simpleHttp "http://localhost:12000/" `shouldReturn` "hello" + simpleHttp "http://localhost:12001/" `shouldReturn` "hello" appWithResponse (literal "foo") - simpleHttp "http://localhost:12000/" `shouldReturn` "foo" + simpleHttp "http://localhost:12001/" `shouldReturn` "foo" it "can deal with large response bodies" $ do appWithResponse [i|(B.take 100000 $ B.cycle #{literal "foo bar baz\n"})|] - simpleHttp "http://localhost:12000/large-response" `shouldReturn` (L.take 100000 $ L.cycle "foo bar baz\n") + simpleHttp "http://localhost:12001/large-response" `shouldReturn` (L.take 100000 $ L.cycle "foo bar baz\n") context "when client closes connection early" $ do it "ignores that client" $ do - h <- connectTo "localhost" (PortNumber 12000) + h <- connectTo "localhost" (PortNumber 12001) hPutStr h "GET / HTTP/1.1\r\n\r\n" hClose h - simpleHttp "http://localhost:12000/" `shouldReturn` "hello" + simpleHttp "http://localhost:12001/" `shouldReturn` "hello"