Safe Haskell | None |
---|
IHP.Test.Mocking
Synopsis
- type ContextParameters application = (?applicationContext :: ApplicationContext, ?context :: RequestContext, ?modelContext :: ModelContext, ?application :: application, InitControllerContext application, ?mocking :: MockContext application)
- data MockContext application = InitControllerContext application => MockContext {
- modelContext :: ModelContext
- requestContext :: RequestContext
- applicationContext :: ApplicationContext
- application :: application
- mockContext :: InitControllerContext application => application -> ConfigBuilder -> IO (MockContext application)
- withContext :: (ContextParameters application => IO a) -> MockContext application -> IO a
- setupWithContext :: (ContextParameters application => IO a) -> MockContext application -> IO (MockContext application)
- mockAction :: forall application controller. (Controller controller, ContextParameters application) => controller -> IO Response
- mockActionResponse :: forall application controller. (Controller controller, ContextParameters application) => controller -> IO ByteString
- mockActionStatus :: forall application controller. (Controller controller, ContextParameters application) => controller -> IO Status
- withParams :: [Param] -> (ContextParameters application => IO a) -> MockContext application -> IO a
- headers :: IO Response -> IO ResponseHeaders
- responseBody :: Response -> IO ByteString
Documentation
type ContextParameters application = (?applicationContext :: ApplicationContext, ?context :: RequestContext, ?modelContext :: ModelContext, ?application :: application, InitControllerContext application, ?mocking :: MockContext application) Source #
data MockContext application Source #
Constructors
InitControllerContext application => MockContext | |
Fields
|
mockContext :: InitControllerContext application => application -> ConfigBuilder -> IO (MockContext application) Source #
Create contexts that can be used for mocking
withContext :: (ContextParameters application => IO a) -> MockContext application -> IO a Source #
Run a IO action, setting implicit params based on supplied mock context
setupWithContext :: (ContextParameters application => IO a) -> MockContext application -> IO (MockContext application) Source #
mockAction :: forall application controller. (Controller controller, ContextParameters application) => controller -> IO Response Source #
Runs a controller action in a mock environment
mockActionResponse :: forall application controller. (Controller controller, ContextParameters application) => controller -> IO ByteString Source #
Get contents of response
mockActionStatus :: forall application controller. (Controller controller, ContextParameters application) => controller -> IO Status Source #
Get HTTP status of the controller
withParams :: [Param] -> (ContextParameters application => IO a) -> MockContext application -> IO a Source #
Add params to the request context, run the action
responseBody :: Response -> IO ByteString Source #