Skip to content

Commit

Permalink
Adjusting after #132
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Stachyra committed Mar 29, 2019
1 parent 90c2efc commit 6558742
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
10 changes: 8 additions & 2 deletions test/integration/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
8 changes: 7 additions & 1 deletion test/integration/Test/Integration/Framework/DSL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 (..) )

Expand Down
8 changes: 3 additions & 5 deletions test/integration/Test/Integration/Framework/Request.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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

0 comments on commit 6558742

Please sign in to comment.