testcontainers-hs
testcontainers-hs copied to clipboard
Expose WaitUntilReady constructors
I'd like to add a custom check, a real connection to the database with a test query. Something like this:
mariaDBReady :: TestDBInfo -> WaitUntilReady
mariaDBReady db = WaitReady $ \container -> do
withFrozenCallStack $ do
let (endpointHost, endpointPort) = containerAddress container db.dbPort
ci =
defaultConnectInfo
{ connectHost = unpack endpointHost
, connectPort = fromIntegral endpointPort
, connectUser = unpack db.dbUsername
, connectPassword = unpack db.dbPassword
, connectDatabase = unpack db.dbName
}
wait = do
r <- try (connect ci >>= flip query_ "select 2 + 3")
case r of
Right [Only (i :: Int)] -> do
pure ()
Left (ex :: IOException) -> do
threadDelay 500000
wait
liftIO wait
This is currently not possible since WaitReady
is not public.