Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
WouldYouKindly authored Jan 17, 2022
1 parent b3b8077 commit 7536dfc
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down Expand Up @@ -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/<YOUR-USER>/.lima/default/sock/docker.sock`

#### How to record a test
```python
from pytest_hoverfly import hoverfly
Expand Down Expand Up @@ -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.

0 comments on commit 7536dfc

Please sign in to comment.