From 6558742c66c146978a4c4f7a349cc894b0af384b Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 29 Mar 2019 09:45:49 +0100 Subject: [PATCH] Adjusting after #132 --- test/integration/Main.hs | 10 ++++++++-- test/integration/Test/Integration/Framework/DSL.hs | 8 +++++++- test/integration/Test/Integration/Framework/Request.hs | 8 +++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/test/integration/Main.hs b/test/integration/Main.hs index a6aea009546..756fe8b9815 100644 --- a/test/integration/Main.hs +++ b/test/integration/Main.hs @@ -24,7 +24,13 @@ import Network.HTTP.Types.Status import Test.Hspec ( SpecWith, afterAll, beforeAll, describe, hspec, it, shouldBe ) import Test.Integration.Framework.DSL - ( Context (..), expectResponseCode, request ) + ( Context (..) + , Headers (..) + , Payload (..) + , expectResponseCode + , json + , request + ) import qualified Cardano.Wallet.Network.HttpBridgeSpec as HttpBridge import qualified Cardano.WalletSpec as Wallet @@ -140,5 +146,5 @@ respCodesSpec = do expectResponseCode @IO status200 response it "POST; Response code 405" $ \ctx -> do - response <- request @Value ctx ("POST", "/get") Nothing Nothing + response <- request @Value ctx ("POST", "/get") None Empty expectResponseCode @IO status405 response diff --git a/test/integration/Test/Integration/Framework/DSL.hs b/test/integration/Test/Integration/Framework/DSL.hs index b3aa521cc43..8ab252049e5 100644 --- a/test/integration/Test/Integration/Framework/DSL.hs +++ b/test/integration/Test/Integration/Framework/DSL.hs @@ -37,7 +37,13 @@ import Language.Haskell.TH.Quote import Test.Hspec.Expectations.Lifted ( shouldBe ) import Test.Integration.Framework.Request - ( Context (..), RequestException (..), request, unsafeRequest ) + ( Context (..) + , Headers (..) + , Payload (..) + , RequestException (..) + , request + , unsafeRequest + ) import Web.HttpApiData ( ToHttpApiData (..) ) diff --git a/test/integration/Test/Integration/Framework/Request.hs b/test/integration/Test/Integration/Framework/Request.hs index d3c76daff32..f9547933648 100644 --- a/test/integration/Test/Integration/Framework/Request.hs +++ b/test/integration/Test/Integration/Framework/Request.hs @@ -26,8 +26,6 @@ import Data.Aeson ( FromJSON ) import Data.ByteString.Lazy ( ByteString ) -import Data.Maybe - ( fromMaybe ) import Data.Text ( Text ) import Network.HTTP.Client @@ -113,7 +111,7 @@ request (Context _ (base, manager)) (verb, path) reqHeaders body = do , requestHeaders = headers } where - headers = case h of + headers = case reqHeaders of Headers x -> x Default -> [ ("Content-Type", "application/json") , ("Accept", "application/json") @@ -146,8 +144,8 @@ unsafeRequest ) => Context -> (Method, Text) - -> Maybe Aeson.Value + -> Payload -> m (HTTP.Status, a) unsafeRequest ctx req body = do - (s, res) <- request ctx req Nothing body + (s, res) <- request ctx req Default body either throwM (pure . (s,)) res