tmp-proc-0.7.2.2: Run 'tmp' processes in integration tests
Copyright(c) 2020-2021 Tim Emiola
LicenseBSD3
MaintainerTim Emiola <[email protected]>
Safe HaskellNone
LanguageHaskell2010

System.TmpProc.Warp

Description

Provides functions that make it easy to run Applications that access services running as tmp procs in integration tests.

Synopsis

Continuation-style setup

testWithApplication :: forall (procs :: [Type]) a. AreProcs procs => HList procs -> (HandlesOf procs -> IO Application) -> ((HandlesOf procs, Port) -> IO a) -> IO a Source #

Set up some ProcHandles then run an Application that uses them on a free port.

Allows the app to configure itself using the tmp procs, then provides a callback with access to the handles.

The tmp procs are shut down when the application is shut down.

testWithReadyApplication :: forall (procs :: [Type]) a. AreProcs procs => (Port -> IO ()) -> HList procs -> (HandlesOf procs -> IO Application) -> ((HandlesOf procs, Port) -> IO a) -> IO a Source #

Set up some ProcHandles then run an Application that uses them on a free port.

Allows the app to configure itself using the tmp procs, then provides a callback with access to the handles.

Also runs a ready action that to determine if the application started correctly.

The tmp procs are shut down when the application is shut down.

testWithTLSApplication :: forall (procs :: [Type]) a. AreProcs procs => TLSSettings -> HList procs -> (HandlesOf procs -> IO Application) -> ((HandlesOf procs, Port) -> IO a) -> IO a Source #

Like testWithApplication, but the port is secured using a 'Warp.TLSSettings. '

testWithReadyTLSApplication :: forall (procs :: [Type]) a. AreProcs procs => TLSSettings -> (Port -> IO ()) -> HList procs -> (HandlesOf procs -> IO Application) -> ((HandlesOf procs, Port) -> IO a) -> IO a Source #

Like testWithReadyApplication; the port is secured with TLSSettings.

ServerHandle

data ServerHandle (procs :: [Type]) Source #

Represents a started Warp application and any AreProcs dependencies.

serverPort :: forall (procs :: [Type]). ServerHandle procs -> Port Source #

The Port on which the ServerHandles server is running.

handles :: forall (procs :: [Type]). AreProcs procs => ServerHandle procs -> HandlesOf procs Source #

The ServerHandles ProcHandles.

shutdown :: forall (procs :: [Type]). AreProcs procs => ServerHandle procs -> IO () Source #

Shuts down the ServerHandle server and its tmp proc dependencies.

runServer :: forall (procs :: [Type]). AreProcs procs => HList procs -> (HandlesOf procs -> IO Application) -> IO (ServerHandle procs) Source #

Runs an Application with ProcHandle dependencies on a free port.

runReadyServer :: forall (procs :: [Type]). AreProcs procs => (Port -> IO ()) -> HList procs -> (HandlesOf procs -> IO Application) -> IO (ServerHandle procs) Source #

Like runServer; with an additional ready that determines if the server is ready.'.

runTLSServer :: forall (procs :: [Type]). AreProcs procs => TLSSettings -> HList procs -> (HandlesOf procs -> IO Application) -> IO (ServerHandle procs) Source #

Like runServer; the port is secured with TLSSettings.

runReadyTLSServer :: forall (procs :: [Type]). AreProcs procs => TLSSettings -> (Port -> IO ()) -> HList procs -> (HandlesOf procs -> IO Application) -> IO (ServerHandle procs) Source #

Like runReadyServer; the port is secured with TLSSettings.

Health check support

checkHealth :: Int -> IO (Either a b) -> IO () Source #

Simplifies writing the health checks used by ready variants of this module.