{"id":17477461,"url":"https://github.com/testcontainers/testcontainers-hs","last_synced_at":"2025-06-15T21:11:20.182Z","repository":{"id":37027145,"uuid":"271516870","full_name":"testcontainers/testcontainers-hs","owner":"testcontainers","description":"Docker containers for your integration tests! http://hackage.haskell.org/package/testcontainers","archived":false,"fork":false,"pushed_at":"2024-04-22T09:45:40.000Z","size":119,"stargazers_count":50,"open_issues_count":9,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-22T18:20:57.243Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/testcontainers.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-11T10:25:21.000Z","updated_at":"2024-05-03T12:37:21.000Z","dependencies_parsed_at":"2024-04-23T02:20:55.357Z","dependency_job_id":null,"html_url":"https://github.com/testcontainers/testcontainers-hs","commit_stats":{"total_commits":103,"total_committers":10,"mean_commits":10.3,"dds":0.6116504854368932,"last_synced_commit":"5a249cfe5e8dec9671dc089e6eb1798cd24546be"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testcontainers%2Ftestcontainers-hs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testcontainers%2Ftestcontainers-hs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testcontainers%2Ftestcontainers-hs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testcontainers%2Ftestcontainers-hs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/testcontainers","download_url":"https://codeload.github.com/testcontainers/testcontainers-hs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246759224,"owners_count":20829068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-18T20:08:08.199Z","updated_at":"2025-04-04T17:30:39.197Z","avatar_url":"https://github.com/testcontainers.png","language":"Haskell","funding_links":[],"categories":["Languages","Haskell"],"sub_categories":[],"readme":"# About\n\nTestcontainers is a Haskell library that provides a friendly API to run Docker\ncontainers. It is designed to create a runtime environment to use during your\nintegration tests\n\n# Example\n\n``` haskell\n{-# LANGUAGE FlexibleContexts  #-}\n{-# LANGUAGE OverloadedStrings #-}\n{-# LANGUAGE RecordWildCards   #-}\nmodule Main where\n\nimport qualified Test.Tasty           as Tasty\nimport qualified Test.Tasty.HUnit     as Tasty\nimport qualified TestContainers.Tasty as TC\n\n\ndata Endpoints = Endpoints\n  {\n    redisHost :: String\n  , redisPort :: Int\n  }\n\n\n-- | Sets up and runs the containers required for this test suite.\nsetupContainers :: TC.MonadDocker m =\u003e m Endpoints\nsetupContainers = do\n\n  -- Launch the container based on the redis:5.0.0 image.\n  redisContainer \u003c- TC.run $ TC.containerRequest (TC.fromTag \"redis:5.0.0\")\n    -- Expose the port 6379 from within the container. The respective port\n    -- on the host machine can be looked up using `containerPort` (see below).\n    TC.\u0026 TC.setExpose [ 6379 ]\n    -- Wait until the container is ready to accept requests. `run` blocks until\n    -- readiness can be established.\n    TC.\u0026 TC.setWaitingFor (TC.waitUntilMappedPortReachable 6379)\n\n  pure $ Endpoints\n    {\n      redisHost = \"0.0.0.0\"\n    , redisPort =\n        -- Look up the corresponding port on the host machine for the exposed\n        -- port 6379.\n        TC.containerPort redisContainer 6379\n    }\n\n\nmain :: IO ()\nmain =\n  Tasty.defaultMain $\n  -- Use `withContainers` to make the containers available in the closed over\n  -- tests. Due to how Tasty handles resources `withContainers` passes down\n  -- an IO action `start` to actually start up the containers. `start` can be\n  -- invoked multiple times, Tasty makes sure to only start up the containrs\n  -- once.\n  --\n  -- `withContainers` ensures the started containers are shut down correctly\n  -- once execution leaves its scope.\n  TC.withContainers setupContainers $ \\start -\u003e\n    Tasty.testGroup \"Some test group\"\n      [\n        Tasty.testCase \"Redis test\" $ do\n          -- Actually start the containers!!\n          Endpoints {..} \u003c- start\n          -- ... assert some properties\n          pure ()\n\n      , Tasty.testCase \"Another Redis test\" $ do\n          -- Invoking `start` twice gives the same Endpoints!\n          Endpoints {..} \u003c- start\n          -- ... assert some properties\n          pure ()\n      ]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestcontainers%2Ftestcontainers-hs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftestcontainers%2Ftestcontainers-hs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestcontainers%2Ftestcontainers-hs/lists"}