From 7536dfc905c371866b4767564302aa2021880a34 Mon Sep 17 00:00:00 2001 From: Alexey Date: Mon, 17 Jan 2022 16:42:08 +0300 Subject: [PATCH] Update README.md --- README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 44210b5..f13f0ff 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![CI](https://github.com/wrike/pytest-hoverfly/actions/workflows/main.yml/badge.svg)](https://github.com/wrike/pytest-hoverfly/actions/workflows/main.yml) -A helper for working with [Hoverfly](https://hoverfly.readthedocs.io/en/latest/) from `pytest`. +A helper for working with [Hoverfly](https://hoverfly.readthedocs.io/en/latest/) from `pytest`. Works both locally and in CI. ### Installation `pip install pytest-hoverfly` @@ -36,6 +36,11 @@ addopts = --hoverfly-simulation-path=tests/simulations ``` +#### Without Docker Desktop +If you're using something like [lima](https://github.com/lima-vm/lima) instead of Docker Desktop, you need to specify a path to Docker API. For lima: + +`export DOCKER_HOST=unix:///Users//.lima/default/sock/docker.sock` + #### How to record a test ```python from pytest_hoverfly import hoverfly @@ -86,3 +91,24 @@ To use a different Hoverfly version, specify `--hoverfly-image`. It must be a va #### Start Hoverfly with custom parameters Use `--hoverfly-args`. It is passed as is to a Hoverfly container. + +### Usage in CI +CI systems like Gitlab CI or Github Actions allow you to run arbitrary services as containers. `pytest-hoverfly` can detect if a Hoverfly instance is already running by looking at certain environment variables. If it detects a running instance, `pytest-hovefly` uses it, and doesn't create a new container. + +For Github Actions: + +``` +services: + hoverfly: + image: spectolabs/hoverfly:v1.3.2 + ports: + - 8500:8500 + - 8888:8888 + + env: + HOVERFLY_HOST: localhost + HOVERFLY_PROXY_PORT: 8500 + HOVERFLY_ADMIN_PORT: 8888 +``` + +Mind that all three variables must be specified.