-- Docs: https://hspec.github.io/hspec-discover.htmlmodule SpecHook whereimport Hasql.Connection qualified as Connectionimport Hasql.Connection.Settings qualified as Settingsimport Pqi.Native qualified as Pqiimport Preludeimport Test.Hspecimport TestcontainersPostgresql qualifiedtype HookedSpec = SpecWith Connection.Connectionhook :: HookedSpec -> Spechook hookedSpec = parallel do byDistro "postgres:10" byDistro "postgres:17" where byDistro tagName = describe (toList tagName) do aroundAll ( \onConnection -> TestcontainersPostgresql.run TestcontainersPostgresql.Config { tagName, auth = TestcontainersPostgresql.TrustAuth, forwardLogs = False } ( \(host, port) -> do let settings = mconcat [ Settings.hostAndPort host port, Settings.user "postgres", Settings.dbname "postgres" ] bracket ( do res <- Connection.acquire Pqi.adapter settings case res of Left err -> fail ("Connection failed: " <> show err) Right conn -> pure conn ) Connection.release onConnection ) ) (parallel hookedSpec)