tmp-proc-0.7.0.0: Run 'tmp' processes in integration tests
Copyright(c) 2020-2021 Tim Emiola
LicenseBSD3
MaintainerTim Emiola <adetokunbo@users.noreply.github.com>
Safe HaskellSafe-Inferred
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 :: 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 :: 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 :: 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 :: 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 Source #

Represents a started Warp application and any AreProcs dependencies.

serverPort :: ServerHandle procs -> Port Source #

The Port on which the ServerHandles server is running.

handles :: AreProcs procs => ServerHandle procs -> HandlesOf procs Source #

The ServerHandles ProcHandles.

shutdown :: AreProcs procs => ServerHandle procs -> IO () Source #

Shuts down the ServerHandle server and its tmp proc dependencies.

runServer :: AreProcs procs => HList procs -> (HandlesOf procs -> IO Application) -> IO (ServerHandle procs) Source #

Runs an Application with ProcHandle dependencies on a free port.

runReadyServer :: 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 :: AreProcs procs => TLSSettings -> HList procs -> (HandlesOf procs -> IO Application) -> IO (ServerHandle procs) Source #

Like runServer; the port is secured with TLSSettings.

runReadyTLSServer :: 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.