From 9e17810329dbfa0adc0ee3042556fbd13f810d5c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 18 Jul 2016 12:22:23 +0200 Subject: test for safer deletion --- server/test/Thermoprint/ServerSpec.hs | 5 +++++ server/thermoprint-server.cabal | 1 + 2 files changed, 6 insertions(+) diff --git a/server/test/Thermoprint/ServerSpec.hs b/server/test/Thermoprint/ServerSpec.hs index 8af210d..334f785 100644 --- a/server/test/Thermoprint/ServerSpec.hs +++ b/server/test/Thermoprint/ServerSpec.hs @@ -42,6 +42,7 @@ import System.IO.Temp import qualified Data.Text as T import Network.Wai.Handler.Warp (defaultSettings, setBeforeMainLoop) +import Network.HTTP.Types.Status (Status(..)) import qualified Data.Map as Map @@ -153,7 +154,11 @@ spec = withSetup $ do (atomically . takeTMVar $ outputChan printer) `shouldReturn` p draftDelete dId drafts `shouldReturn` [] + draftReplace dId Nothing p `shouldThrow` is404 where Client{..} = mkClient' $ BaseUrl Http "localhost" 3000 "" + is404 :: ServantError -> Bool + is404 e@(FailureResponse {}) = statusCode (responseStatus e) == 404 + is404 _ = False diff --git a/server/thermoprint-server.cabal b/server/thermoprint-server.cabal index afb62db..259abf3 100644 --- a/server/thermoprint-server.cabal +++ b/server/thermoprint-server.cabal @@ -93,6 +93,7 @@ Test-Suite tests , exceptions >=0.8.0 && <1 , containers >=0.5.6 && <1 , async >=2.1.0 && <3 + , http-types >=0.9.1 && <1 executable thermoprint-server main-is: Main.hs -- cgit v1.2.3