packages feed

sydtest-servant 0.0.0.0 → 0.1.0.0

raw patch · 4 files changed

+21/−12 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Test.Syd.Servant: clientEnvSetupFunc :: forall api. HasServer api '[] => Proxy api -> Manager -> SetupFunc (ServerT api Handler) ClientEnv
+ Test.Syd.Servant: clientEnvSetupFunc :: forall api. HasServer api '[] => Proxy api -> Manager -> ServerT api Handler -> SetupFunc ClientEnv
- Test.Syd.Servant: servantSpecWithSetupFunc :: forall api a. HasServer api '[] => Proxy api -> SetupFunc a (ServerT api Handler) -> ServantSpec -> SpecWith a
+ Test.Syd.Servant: servantSpecWithSetupFunc :: forall api. HasServer api '[] => Proxy api -> SetupFunc (ServerT api Handler) -> ServantSpec -> Spec

Files

src/Test/Syd/Servant.hs view
@@ -25,16 +25,25 @@ servantSpec py server = servantSpecWithSetupFunc py (pure server)  -- | Run a servant server around every test, based around the given 'SetupFunc'-servantSpecWithSetupFunc :: forall api a. HasServer api '[] => Servant.Proxy api -> SetupFunc a (ServerT api Handler) -> ServantSpec -> SpecWith a-servantSpecWithSetupFunc py serverSetupFunc =-  beforeAll (newManager defaultManagerSettings)-    . setupAroundWith' (\man -> serverSetupFunc `connectSetupFunc` clientEnvSetupFunc py man)+servantSpecWithSetupFunc :: forall api. HasServer api '[] => Servant.Proxy api -> SetupFunc (ServerT api Handler) -> ServantSpec -> Spec+servantSpecWithSetupFunc py setupFunc = servantSpecWithSetupFunc' py $ \() -> setupFunc -clientEnvSetupFunc :: forall api. HasServer api '[] => Servant.Proxy api -> HTTP.Manager -> SetupFunc (ServerT api Handler) ClientEnv-clientEnvSetupFunc py man = wrapSetupFunc $ \server -> do+servantSpecWithSetupFunc' :: forall api inner. HasServer api '[] => Servant.Proxy api -> (inner -> SetupFunc (ServerT api Handler)) -> ServantSpec -> SpecWith inner+servantSpecWithSetupFunc' py serverSetupFunc = managerSpec . setupAroundWith' (\man inner -> serverSetupFunc inner >>= clientEnvSetupFunc py man)++clientEnvSetupFunc :: forall api. HasServer api '[] => Servant.Proxy api -> HTTP.Manager -> ServerT api Handler -> SetupFunc ClientEnv+clientEnvSetupFunc py man server = do   let application = serve py server-  p <- unwrapSetupFunc applicationSetupFunc application-  pure $ mkClientEnv man (BaseUrl Http "127.0.0.1" p "")+  p <- applicationSetupFunc application+  pure $+    mkClientEnv+      man+      ( BaseUrl+          Http+          "127.0.0.1"+          (fromIntegral p) -- Safe because it is PortNumber -> Int+          ""+      )  testClient :: ClientEnv -> ClientM a -> IO a testClient cenv func = do
sydtest-servant.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           sydtest-servant-version:        0.0.0.0+version:        0.1.0.0 synopsis:       A servant companion library for sydtest category:       Testing homepage:       https://github.com/NorfairKing/sydtest#readme
test/Test/Syd/Servant/Example.hs view
@@ -13,7 +13,7 @@  type ExampleAPI =   "get" :> Get '[JSON] Int-    :<|> "add" :> ReqBody '[JSON] Int :> PostNoContent '[JSON] NoContent+    :<|> "add" :> ReqBody '[JSON] Int :> Post '[JSON] NoContent  exampleServer :: TVar Int -> Server ExampleAPI exampleServer var = serveGet :<|> serveAdd
test/Test/Syd/ServantSpec.hs view
@@ -6,8 +6,8 @@ import Test.Syd.Servant import Test.Syd.Servant.Example -exampleSetupFunc :: SetupFunc () (Server ExampleAPI)-exampleSetupFunc = SetupFunc $ \func () -> do+exampleSetupFunc :: SetupFunc (Server ExampleAPI)+exampleSetupFunc = SetupFunc $ \func -> do   var <- newTVarIO 0   func $ exampleServer var