{"id":15647982,"url":"https://github.com/danielsiwiec/containerized-contract-tests","last_synced_at":"2026-05-01T15:33:52.068Z","repository":{"id":144990927,"uuid":"153041494","full_name":"danielsiwiec/containerized-contract-tests","owner":"danielsiwiec","description":null,"archived":false,"fork":false,"pushed_at":"2018-11-19T06:11:54.000Z","size":78,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T01:24:31.694Z","etag":null,"topics":["cdc","consumer-driven-contracts","docker","testing"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielsiwiec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-15T02:23:59.000Z","updated_at":"2018-11-19T06:11:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"eb46e421-fc93-47e4-9d77-c811854831c0","html_url":"https://github.com/danielsiwiec/containerized-contract-tests","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsiwiec%2Fcontainerized-contract-tests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsiwiec%2Fcontainerized-contract-tests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsiwiec%2Fcontainerized-contract-tests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsiwiec%2Fcontainerized-contract-tests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielsiwiec","download_url":"https://codeload.github.com/danielsiwiec/containerized-contract-tests/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246258885,"owners_count":20748573,"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":["cdc","consumer-driven-contracts","docker","testing"],"created_at":"2024-10-03T12:22:26.982Z","updated_at":"2026-05-01T15:33:47.035Z","avatar_url":"https://github.com/danielsiwiec.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Containerized Consumer Driven Contracts\n\nThis demo will walk you through the following steps:\n\n1. Starting a provider service (express API)\n1. Running a consumer application (node client)\n1. Publishing a contract by a consumer\n1. Exercising the contract against a provider\n\n## Typical workflow\n\n1. The *Provider* builds a service\n1. The *Consumer* integrates with it and has now a dependency on part of the *Provider* service\n1. The *Consumer* specifies its dependency in a suite of Contract Tests, in a technology of their choosing\n1. The *Consumer* publishes the image\n1. The *Provider* picks up the image and runs it in a container, passing pre-defined variables (hostname, etc)\n1. The *Provider* subscribes to new versions of the image and runs it on every new version\n\n## Prerequisites\n\n* Docker\n\n## Provider\n\nThis is an animal service with a single endpoint **GET \\\\{animal}** returning a JSON body. In this section we will start the service and exercise its endpoint.\n\n### Running\n\nStart the *Provider* service:\n\n```shell\nmake provider\n```\n\nThis will build a Docker image for the *Provider* and start a container.\n\nAt this point, the server is running. In order to simulate a real-life scenario of the server running in the cloud, a tunneling service ([ngrok](https://ngrok.com/)) has been used. The output will give you a publicly accessible endpoint for the service (e.g. https://c0587a05.ngrok.io)\n\nYou can exercise the endpoint in the following way:\n\n```bash\ncurl https://c0587a05.ngrok.io/dog\n```\n\nYou should see the following response:\n\n```json\n{\n  \"family\": \"mamal\",\n  \"sounds\": \"woof!\",\n  \"famousMember\": \"Odie\"\n}\n```\n\n## Consumer\n\nThe *Consumer* is an application relying on the *Provider* for it's functionality. In this section we will run the consumer client application, as well as run contract tests against the provider.\n\n### Running\n\nThe consumer application needs the provider's endpoint. It'll be read from the *Provider* container and passed through an environment variable. Run the *Consumer* client:\n\n```shell\nmake consumer\n```\n\nThis command builds a consumer image and runs the container, passing in the endpoint as an environment variable. The variable is read from the *Provider* container.\n\nYou should see a similar output to this:\n\n```shell\nDuck is a bird and it makes quack quack!\n```\n\n## Publishing and exercising the contract\nIn this section, we will do the following:\n\n1. (Consumer) Build and publish the contract test Docker image\n1. (Provider) Start the container and run the contract tests against the instance\n\n### Build and publish the contract image\n\nGo to the contract folder:\n\n```shell\nmake contract-build\n```\n\nThis will build a Docker image with the contract tests in it.\n\n### Exercise the contract against the provider\n\nStart a container to run the contract tests and pass the PROVIDER_URL variable:\n\n```shell\nmake contract-run\n```\n\nSimilar as before - the variable is read from the *Provider* container.\n\nYou should see an output similar to this:\n\n```shell\nPASS tests/duck.test.js\n  Animal service\n    ✓ should describe a duck (569ms)\n\nTest Suites: 1 passed, 1 total\nTests:       1 passed, 1 total\nSnapshots:   0 total\nTime:        0.986s\nRan all test suites.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielsiwiec%2Fcontainerized-contract-tests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielsiwiec%2Fcontainerized-contract-tests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielsiwiec%2Fcontainerized-contract-tests/lists"}