Skip to content

Commit 9504562

Browse files
committed
Add mocks target to makefile
Signed-off-by: Lorenzo <[email protected]>
1 parent 53bbd2b commit 9504562

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
test:
22
docker compose -f docker-compose.test.yaml up toxiproxy integration_test --abort-on-container-exit
3+
4+
mocks:
5+
docker run --rm -v $(PWD):/src -w /src vektra/mockery:v2.53.3 --config .mockery.yaml
6+
7+
.PHONY: test mocks

docs/testing.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ make test
1515
For generating mocks, the `mockery` tool is used. For `mockery` installation, follow the instructions on
1616
the [official docs](https://vektra.github.io/mockery/latest/).
1717

18-
**Note**: Mock generation is also run as part of the CI pipeline, so you can check if the mocks are up-to-date by
19-
running the tests. However, It is recommended to run the tests locally before pushing your changes.
18+
**Note**: Mocks are not checked in and are instead generated on-the-fly as part of the CI pipeline. If your local tests fail, it may be due to your mocks being out-of-date. This can be fixed by re-generating the mocks. It is recommended to run the tests locally before pushing your changes.
2019

2120
When adding new interfaces and needing to generate mocks, you should:
2221

@@ -28,4 +27,15 @@ When adding new interfaces and needing to generate mocks, you should:
2827
```sh
2928
mockery
3029
```
30+
Alternatively, you may generate the mocks via make target:
31+
```sh
32+
make mocks
33+
```
34+
35+
## Toxiproxy
3136

37+
For testing the resilience of the library against network issues, some tests use Toxiproxy.
38+
If you wish to run the network tests locally (without docker compose) you need to:
39+
- Install [toxiproxy](https://github.com/Shopify/toxiproxy) for your platform
40+
- Start a local toxiproxy - `toxiproxy-server -port 8474 -host localhost`
41+
- Run the tests - `go fmt ./... && go vet ./... && go test -v -count=1 -failfast ./...`

0 commit comments

Comments
 (0)