-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Test a simple service with backends running on docker using tmp-proc -- -- An example of testing a service that uses Postgresql and Redis where -- these backends are launched in docker via simple test setup code that -- uses tmp-proc @package tmp-proc-example @version 0.5.3.1 -- | Specifies the schema of the data accessed by the demo service. module TmpProc.Example1.Schema type ContactID = Int64 data Contact Contact :: !Text -> !Text -> !Int -> !Text -> Contact [contactEmail] :: Contact -> !Text [contactName] :: Contact -> !Text [contactAge] :: Contact -> !Int [contactTitle] :: Contact -> !Text type ContactId = Key Contact migrateAll :: Migration entityDefListFormigrateAll :: [EntityDef] parseContact :: Object -> Parser Contact instance GHC.Read.Read TmpProc.Example1.Schema.Contact instance GHC.Show.Show TmpProc.Example1.Schema.Contact instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key TmpProc.Example1.Schema.Contact) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key TmpProc.Example1.Schema.Contact) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key TmpProc.Example1.Schema.Contact) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key TmpProc.Example1.Schema.Contact) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key TmpProc.Example1.Schema.Contact) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key TmpProc.Example1.Schema.Contact) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key TmpProc.Example1.Schema.Contact) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key TmpProc.Example1.Schema.Contact) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key TmpProc.Example1.Schema.Contact) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key TmpProc.Example1.Schema.Contact) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key TmpProc.Example1.Schema.Contact) instance Database.Persist.Class.PersistEntity.PersistEntity TmpProc.Example1.Schema.Contact instance Database.Persist.Class.PersistField.PersistField TmpProc.Example1.Schema.Contact instance Database.Persist.Sql.Class.PersistFieldSql TmpProc.Example1.Schema.Contact instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend TmpProc.Example1.Schema.Contact instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey TmpProc.Example1.Schema.Contact instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey TmpProc.Example1.Schema.Contact instance Database.Persist.Class.PersistEntity.SymbolToField "id" TmpProc.Example1.Schema.Contact (Database.Persist.Class.PersistEntity.Key TmpProc.Example1.Schema.Contact) instance Database.Persist.Class.PersistEntity.SymbolToField "email" TmpProc.Example1.Schema.Contact Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SymbolToField "name" TmpProc.Example1.Schema.Contact Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SymbolToField "age" TmpProc.Example1.Schema.Contact GHC.Types.Int instance Database.Persist.Class.PersistEntity.SymbolToField "title" TmpProc.Example1.Schema.Contact Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SafeToInsert TmpProc.Example1.Schema.Contact instance Data.Aeson.Types.ToJSON.ToJSON TmpProc.Example1.Schema.Contact instance Data.Aeson.Types.FromJSON.FromJSON TmpProc.Example1.Schema.Contact -- | Specifies the API provided by the demo service. module TmpProc.Example1.Routes -- | API allowing Contact creation and retrieval. type ContactsAPI = "contacts" :> Capture "contactid" ContactID :> Get '[JSON] Contact :<|> "contacts" :> ReqBody '[JSON] Contact :> Post '[JSON] ContactID -- | For convenience in Servant combinators where a proxy is -- required. contactsAPI :: Proxy ContactsAPI -- | Defines data access combinators used by the demo service module TmpProc.Example1.Database create :: Locator -> Contact -> IO ContactID fetch :: Locator -> ContactID -> IO (Maybe Contact) remove :: Locator -> ContactID -> IO () migrateDB :: Locator -> IO () -- | Specifies the database to connect to . type Locator = ConnectionString -- | A default for local development . defaultLoc :: Locator -- | Defines client combinators that access the demo service module TmpProc.Example1.Client -- | Fetch a contact via the API. fetch :: ContactID -> ClientM Contact -- | Create a contact via the API. create :: Contact -> ClientM ContactID -- | Implements a cache for the demo service module TmpProc.Example1.Cache deleteContact :: Locator -> ContactID -> IO () loadContact :: Locator -> ContactID -> IO (Maybe Contact) saveContact :: Locator -> ContactID -> Contact -> IO () runRedisAction :: Locator -> Redis a -> IO a -- | Specifies the Redis instance to use as a cache . type Locator = ConnectInfo -- | A default for local development . defaultLoc :: Locator -- | Implements the demo service. module TmpProc.Example1.Server -- | Runs waiApp on the given port. runServer' :: Port -> Locator -> Locator -> IO () -- | Runs waiApp using defaults for local development. runServer :: IO () -- | An Application that runs the server using the given DB and -- Cache. waiApp :: Locator -> Locator -> Application -- | An demo Tasty test that use tmp-proc module TmpProc.Example1.IntegrationTaste -- | The test uses a Postgres database . dbProc :: TmpPostgres -- | The test uses Redis as a cache. cacheProc :: TmpRedis -- | Specifies the procs to be launched as test fixtures. testProcs :: HList '[TmpPostgres, TmpRedis] main :: IO () tests :: IO Fixture -> TestTree hasInCache :: ServerHandle '[TmpPostgres, TmpRedis] -> ContactID -> IO Bool hasInDb :: ServerHandle '[TmpPostgres, TmpRedis] -> ContactID -> IO Bool -- | The full test fixture. -- -- It allows tests to -- -- type Fixture = (ServerHandle '[TmpPostgres, TmpRedis], ClientEnv) mkFixture :: IO Fixture shutdown' :: Fixture -> IO () cacheLocFrom :: ProcHandle TmpRedis -> IO Locator clientEnvOf :: AreProcs procs => ServerHandle procs -> IO ClientEnv testContact :: Contact -- | Specifies the schema of the data accessed by the demo service. module TmpProc.Example2.Schema type ContactID = Int64 data Contact Contact :: !Text -> !Text -> !Int -> !Text -> Contact [contactEmail] :: Contact -> !Text [contactName] :: Contact -> !Text [contactAge] :: Contact -> !Int [contactTitle] :: Contact -> !Text type ContactId = Key Contact migrateAll :: Migration entityDefListFormigrateAll :: [EntityDef] parseContact :: Object -> Parser Contact instance GHC.Read.Read TmpProc.Example2.Schema.Contact instance GHC.Show.Show TmpProc.Example2.Schema.Contact instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key TmpProc.Example2.Schema.Contact) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key TmpProc.Example2.Schema.Contact) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key TmpProc.Example2.Schema.Contact) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key TmpProc.Example2.Schema.Contact) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key TmpProc.Example2.Schema.Contact) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key TmpProc.Example2.Schema.Contact) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key TmpProc.Example2.Schema.Contact) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key TmpProc.Example2.Schema.Contact) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key TmpProc.Example2.Schema.Contact) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key TmpProc.Example2.Schema.Contact) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key TmpProc.Example2.Schema.Contact) instance Database.Persist.Class.PersistEntity.PersistEntity TmpProc.Example2.Schema.Contact instance Database.Persist.Class.PersistField.PersistField TmpProc.Example2.Schema.Contact instance Database.Persist.Sql.Class.PersistFieldSql TmpProc.Example2.Schema.Contact instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend TmpProc.Example2.Schema.Contact instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey TmpProc.Example2.Schema.Contact instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey TmpProc.Example2.Schema.Contact instance Database.Persist.Class.PersistEntity.SymbolToField "id" TmpProc.Example2.Schema.Contact (Database.Persist.Class.PersistEntity.Key TmpProc.Example2.Schema.Contact) instance Database.Persist.Class.PersistEntity.SymbolToField "email" TmpProc.Example2.Schema.Contact Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SymbolToField "name" TmpProc.Example2.Schema.Contact Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SymbolToField "age" TmpProc.Example2.Schema.Contact GHC.Types.Int instance Database.Persist.Class.PersistEntity.SymbolToField "title" TmpProc.Example2.Schema.Contact Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SafeToInsert TmpProc.Example2.Schema.Contact instance Data.Aeson.Types.ToJSON.ToJSON TmpProc.Example2.Schema.Contact instance Data.Aeson.Types.FromJSON.FromJSON TmpProc.Example2.Schema.Contact -- | Specifies the API provided by the demo service. module TmpProc.Example2.Routes -- | API allowing Contact creation and retrieval. type ContactsAPI = "contacts" :> Capture "contactid" ContactID :> Get '[JSON] Contact :<|> "contacts" :> ReqBody '[JSON] Contact :> Post '[JSON] ContactID -- | For convenience in Servant combinators where a proxy is -- required. contactsAPI :: Proxy ContactsAPI module TmpProc.Example2.Database create :: Locator -> Contact -> IO ContactID fetch :: Locator -> ContactID -> IO (Maybe Contact) remove :: Locator -> ContactID -> IO () migrateDB :: Locator -> IO () -- | Specifies the database to connect to . type Locator = ConnectionString -- | A default for local development . defaultLoc :: Locator -- | Defines client combinators that access the demo service module TmpProc.Example2.Client -- | Fetch a contact via the API. fetch :: ContactID -> ClientM Contact -- | Create a contact via the API. create :: Contact -> ClientM ContactID -- | Implements a cache for the demo service module TmpProc.Example2.Cache deleteContact :: Connection -> ContactID -> IO () loadContact :: Connection -> ContactID -> IO (Maybe Contact) saveContact :: Connection -> ContactID -> Contact -> IO () runRedisAction :: Connection -> Redis a -> IO a -- | A threadsafe pool of network connections to a Redis server. Use the -- connect function to create one. data Connection -- | A default for local development . defaultConn :: IO Connection -- | Implements a demo service. module TmpProc.Example2.Server -- | An application-level environment suitable for storing in a Reader. data AppEnv AppEnv :: !Locator -> !Connection -> AppEnv [aeDbLocator] :: AppEnv -> !Locator [aeCacheLocator] :: AppEnv -> !Connection -- | Runs waiApp on the given port. runServer' :: IO AppEnv -> Port -> IO () -- | Runs waiApp using defaults for local development. runServer :: IO () -- | An Application that runs the server using the given DB and -- Cache. waiApp :: AppEnv -> Application instance Control.Monad.IO.Class.MonadIO TmpProc.Example2.Server.App instance Control.Monad.Reader.Class.MonadReader TmpProc.Example2.Server.AppEnv TmpProc.Example2.Server.App instance Control.Monad.Catch.MonadThrow TmpProc.Example2.Server.App instance Control.Monad.Catch.MonadMask TmpProc.Example2.Server.App instance Control.Monad.Catch.MonadCatch TmpProc.Example2.Server.App instance GHC.Base.Monad TmpProc.Example2.Server.App instance GHC.Base.Functor TmpProc.Example2.Server.App instance GHC.Base.Applicative TmpProc.Example2.Server.App instance TmpProc.Example2.Server.Has TmpProc.Example2.Database.Locator TmpProc.Example2.Server.AppEnv instance TmpProc.Example2.Server.Has Database.Redis.Connection.Connection TmpProc.Example2.Server.AppEnv -- | An demo HSpec test that use tmp-proc module TmpProc.Example2.IntegrationSpec -- | The test uses a Postgres database . dbProc :: TmpPostgres -- | The test uses Redis as a cache. cacheProc :: TmpRedis -- | Specifies the procs to be launched as test fixtures. testProcs :: HList '[TmpPostgres, TmpRedis] -- | Specifies the expected behaviour. spec :: Spec -- | Simplifies the test cases -- -- Note the use of the HasHandle constraint to indicate what -- TmpProcs the function uses. hasInCache :: HasHandle TmpRedis procs => ServerHandle procs -> ContactID -> IO Bool -- | Simplifies the test cases -- -- Here, ServerHandle specifies the full list of types required by the -- calling test code. hasInDb :: ServerHandle '[TmpPostgres, TmpRedis] -> ContactID -> IO Bool -- | The full test fixture. -- -- It allows tests to -- -- type Fixture = (ServerHandle ('[TmpPostgres, TmpRedis]), ClientEnv) mkFixture :: IO Fixture shutdown' :: Fixture -> IO () clientEnvOf :: AreProcs procs => ServerHandle procs -> IO ClientEnv testContact :: Contact