packages feed

tmp-proc-rabbitmq 0.5.1.4 → 0.5.3.0

raw patch · 4 files changed

+73/−61 lines, 4 filesdep ~amqpdep ~tmp-proc

Dependency ranges changed: amqp, tmp-proc

Files

ChangeLog.md view
@@ -1,5 +1,17 @@ # Revision history for tmp-proc-rabbitmq +`tmp-proc-rabbitmq` uses [PVP Versioning][1].++## 0.5.3.0 -- 2023-08-11++* Use the new `only` constructor+* Refactor the integration test++## 0.5.2.0 -- 2023-07-20++* Restrict the lower bounds of amqp and tmp-proc to prevent+  depending on the connection package+ ## 0.5.1.4 -- 2023-07-12  * Extend the version bounds of bytestring to allow 0.12@@ -16,3 +28,5 @@  * First version * Initial upload to hackage++[1]: https://pvp.haskell.org
src/System/TmpProc/Docker/RabbitMQ.hs view
@@ -1,11 +1,12 @@-{-# LANGUAGE DataKinds             #-}+{-# LANGUAGE DataKinds #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE NamedFieldPuns        #-}-{-# LANGUAGE OverloadedStrings     #-}-{-# LANGUAGE TypeApplications      #-}-{-# LANGUAGE TypeFamilies          #-}+{-# LANGUAGE NamedFieldPuns #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_HADDOCK prune not-home #-}-{-|++{- | Copyright   : (c) 2020-2021 Tim Emiola SPDX-License-Identifier: BSD3 Maintainer  : Tim Emiola <adetokunbo@users.noreply.github.com >@@ -16,11 +17,10 @@  It's also possible to write other instances that launch @RabbitMQ@ in different ways; for those, this instance can be used as a reference example.- -} module System.TmpProc.Docker.RabbitMQ   ( -- * 'Proc' instance-    TmpRabbitMQ(..)+    TmpRabbitMQ (..)      -- * Useful definitions   , aProc@@ -32,36 +32,44 @@ where  import qualified Data.ByteString.Char8 as C8-import           Data.Proxy            (Proxy(..))-import qualified Data.Text             as Text--import           Network.AMQP--import           System.TmpProc        (Connectable (..), HList (..), HandlesOf,-                                        HostIpAddress, Proc (..),-                                        ProcHandle (..), SvcURI, startupAll,-                                        toPinged, withTmpConn)+import Data.Proxy (Proxy (..))+import qualified Data.Text as Text+import Network.AMQP+import System.TmpProc+  ( Connectable (..)+  , HList (..)+  , HandlesOf+  , HostIpAddress+  , Proc (..)+  , ProcHandle (..)+  , SvcURI+  , only+  , startupAll+  , toPinged+  , withTmpConn+  )  -{-| A singleton 'HList' containing a 'TmpRabbitMQ'. -}+-- | A singleton 'HList' containing a 'TmpRabbitMQ'. aProc :: HList '[TmpRabbitMQ]-aProc = TmpRabbitMQ `HCons` HNil+aProc = only TmpRabbitMQ  -{-| An 'HList' that just contains the handle created by 'aProc'. -}+-- | An 'HList' that just contains the handle created by 'aProc'. aHandle :: IO (HandlesOf '[TmpRabbitMQ]) aHandle = startupAll aProc  -{-| Provides the capability to launch a RabbitMQ instance as a @tmp proc@. -}+-- | Provides the capability to launch a RabbitMQ instance as a @tmp proc@. data TmpRabbitMQ = TmpRabbitMQ  -{-| Specifies how to run @RabbitMQ@ as a @tmp proc@. -}+-- | Specifies how to run @RabbitMQ@ as a @tmp proc@. instance Proc TmpRabbitMQ where   type Image TmpRabbitMQ = "rabbitmq:3.9"   type Name TmpRabbitMQ = "a-rabbitmq-server" +   uriOf = mkUri'   runArgs = []   ping = toPinged @AMQPException Proxy . openConn'@@ -69,20 +77,21 @@   pingGap = 3 * 1000000  -{-| Specifies how to connect to a tmp @RabbitMQ@ service. -}+-- | Specifies how to connect to a tmp @RabbitMQ@ service. instance Connectable TmpRabbitMQ where   type Conn TmpRabbitMQ = Connection +   openConn = openConn'   closeConn = closeConnection  -{-| Makes a uri using the guest password . -}+-- | Makes a uri using the guest password . mkUri' :: HostIpAddress -> SvcURI mkUri' ip =   "amqp://guest:guest@"-  <> C8.pack (Text.unpack ip)-  <> ":5672@/%2f"+    <> C8.pack (Text.unpack ip)+    <> ":5672@/%2f"   openConn' :: ProcHandle TmpRabbitMQ -> IO Connection
test/Test/TmpProc/Docker/RabbitMQSpec.hs view
@@ -1,41 +1,28 @@-{-# LANGUAGE DataKinds         #-}+{-# LANGUAGE DataKinds #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeApplications  #-}-module Test.TmpProc.Docker.RabbitMQSpec where--import           Test.Hspec-import           Test.Hspec.TmpProc+{-# LANGUAGE TypeApplications #-} -import           Data.Proxy                     (Proxy (..))-import qualified Data.Text                      as Text+module Test.TmpProc.Docker.RabbitMQSpec where -import           System.TmpProc.Docker.RabbitMQ+import Data.Proxy (Proxy (..))+import qualified Data.Text as Text+import System.TmpProc.Docker.RabbitMQ+import Test.Hspec+import Test.Hspec.TmpProc   spec :: Spec spec = tdescribe desc $ do-  beforeAll setupHandles $ afterAll terminateAll $ do-+  beforeAll (startupAll aProc) $ afterAll terminateAll $ do     context "when using the Proc from the HList by its 'Name'" $ do-       context "ixPing" $ do--        it "should succeed" $ \hs-          -> ixPing @"a-rabbitmq-server" Proxy hs `shouldReturn` OK+        it "should succeed" $ \hs ->+          ixPing @"a-rabbitmq-server" Proxy hs `shouldReturn` OK        context "ixReset" $ do--        it "should succeed" $ \hs-          -> ixReset @"a-rabbitmq-server" Proxy hs `shouldReturn` ()---setupHandles :: IO (HList '[ProcHandle TmpRabbitMQ])-setupHandles = startupAll $ testProc `HCons` HNil---testProc :: TmpRabbitMQ-testProc = TmpRabbitMQ+        it "should succeed" $ \hs ->+          ixReset @"a-rabbitmq-server" Proxy hs `shouldReturn` ()   desc :: String-desc = "Tmp.Proc:RabbitMQ:" ++ Text.unpack (nameOf testProc)+desc = "Tmp.Proc:RabbitMQ:" ++ Text.unpack (nameOf $ hHead aProc)
tmp-proc-rabbitmq.cabal view
@@ -1,16 +1,16 @@ cabal-version:      3.0 name:               tmp-proc-rabbitmq-version:            0.5.1.4-synopsis:           Shows how to run RabbitMQ as a tmp proc+version:            0.5.3.0+synopsis:           Launch RabbitMQ in docker using tmp-proc description:-  An example of using tmp-proc to launch dockerized RabbitMQ in integration tests.+  Demos how to use tmp-proc to run RabbitMQ in docker in a unittest.  license:            BSD-3-Clause license-file:       LICENSE copyright:          2021 Tim Emiola author:             Tim Emiola maintainer:         adetokunbo@users.noreply.github.com-category:           testing+category:           testing, docker bug-reports:        https://github.com/adetokunbo/tmp-proc/issues build-type:         Simple extra-source-files:@@ -18,23 +18,25 @@   README.md tested-with:   GHC == 8.8.4-  GHC == 8.10.5   GHC == 8.10.7-  GHC == 9.2.2+  GHC == 9.0.2+  GHC == 9.2.8+  GHC == 9.4.5  source-repository head   type:     git   location: https://github.com/adetokunbo/tmp-proc.git+  subdir:   tmp-proc-rabbitmq  library   exposed-modules:  System.TmpProc.Docker.RabbitMQ   hs-source-dirs:   src   build-depends:-    , amqp        ^>=0.22+    , amqp        >=0.22.1 && < 0.23     , base        >=4.11     && <5     , bytestring  >=0.10.8.2 && <0.12.1     , text        >=1.2.3 && <2.2-    , tmp-proc    >=0.5 && <0.6+    , tmp-proc    >=0.5.2 && <0.6    default-language: Haskell2010   ghc-options:      -fno-ignore-asserts -Wall