[tests] integration tests work now

parent cbde147c
Pipeline #6357 failed with stages
in 13 minutes and 3 seconds
...@@ -211,7 +211,8 @@ test-suite test-pgmq-integration ...@@ -211,7 +211,8 @@ test-suite test-pgmq-integration
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
other-modules: Test.Integration.PGMQ.Simple other-modules: Test.Integration.Broker
, Test.Integration.PGMQ.Simple
build-depends: base ^>=4.17.2.0 build-depends: base ^>=4.17.2.0
, aeson >= 1.4 && < 2.3 , aeson >= 1.4 && < 2.3
......
module Test.Integration.Broker
-- ( brokerSpec )
where
...@@ -45,12 +45,20 @@ withConn :: (TestEnv -> IO ()) -> IO () ...@@ -45,12 +45,20 @@ withConn :: (TestEnv -> IO ()) -> IO ()
withConn = bracket setUpConn dropConn withConn = bracket setUpConn dropConn
withPGMQ :: (TestEnv -> IO ()) -> IO () withPGMQ :: (TestEnv -> IO ()) -> IO ()
withPGMQ f = withConn $ \testEnv -> bracket (setUpPGMQ testEnv) (\_ -> pure ()) (\_ -> f testEnv) withPGMQ f = withConn $ \testEnv -> bracket (setUpPGMQ testEnv) (tearDownPGMQ testEnv) (\_ -> f testEnv)
where where
setUpPGMQ (TestEnv { conn, queue }) = do setUpPGMQ (TestEnv { conn, queue }) = do
PGMQ.initialize conn PGMQ.initialize conn
-- TODO Uncomment when dropping a non-existing queue is safe -- -- TODO Should be just PGMQ.dropQueue, but it raises errors currently
-- PGMQ.dropQueue conn queue -- -- https://github.com/tembo-io/pgmq/issues/275
-- -- NOTE createQueue && purgeQueue aren't sufficient because
-- -- purgeQueue doesn't remove archived messages
-- PGMQ.createQueue conn queue
PGMQ.dropQueue conn queue
PGMQ.createQueue conn queue
tearDownPGMQ (TestEnv { conn, queue }) _ = do
PGMQ.dropQueue conn queue
pgmqSimpleTests :: Spec pgmqSimpleTests :: Spec
...@@ -63,18 +71,11 @@ pgmqSimpleTests = sequential $ aroundAll withPGMQ $ describe "PGMQ Simple" $ do ...@@ -63,18 +71,11 @@ pgmqSimpleTests = sequential $ aroundAll withPGMQ $ describe "PGMQ Simple" $ do
-- metrics `shouldSatisfy` isNothing -- metrics `shouldSatisfy` isNothing
it "can get metrics for an empty queue" $ \(TestEnv { conn, queue }) -> do it "can get metrics for an empty queue" $ \(TestEnv { conn, queue }) -> do
-- Create if it doesn't exist
PGMQ.createQueue conn queue
-- Drop since we're sure it exists now
PGMQ.dropQueue conn queue
-- Now it's empty
PGMQ.createQueue conn queue
metrics <- PGMQ.getMetrics conn queue metrics <- PGMQ.getMetrics conn queue
metrics `shouldSatisfy` isJust metrics `shouldSatisfy` isJust
(PGMQ.queueLength <$> metrics) `shouldBe` (Just 0) (PGMQ.queueLength <$> metrics) `shouldBe` (Just 0)
-- let (Just (PGMQ.Metrics { .. })) = metrics
-- queueName `shouldBe` queue
-- totalMessages `shouldBe` 0
it "listQueues properly returns our queue" $ \(TestEnv { conn, queue }) -> do
queues <- PGMQ.listQueues conn
((\(PGMQ.QueueInfo { queueName }) -> queueName) <$> queues) `shouldContain` [queue]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment