Skip to content

Commit c69a15a

Browse files
authored
Merge pull request #395 from sanders41/contributing
Update the contributing guide to include insta
2 parents 513b8b7 + ead70a7 commit c69a15a

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

CONTRIBUTING.md

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,43 @@ git pull upstream main --ff-only
6363

6464
### Code linting, formatting, and tests
6565

66-
You can run linting on your code at any time with:
66+
#### Run linting
6767

6868
```sh
6969
cargo clippy --all-targets
7070
```
7171

72-
To format the code run:
72+
#### Run the code formater
7373

7474
```sh
75-
cargo fmt
75+
cargo fmt --all
76+
```
77+
78+
#### Testing the code
79+
80+
[insta](https://insta.rs") is used for snapshot testing. It is recommended
81+
to install [cargo-insta](https://github.com/mitsuhiko/insta/tree/master/cargo-insta) to run the
82+
tests
83+
84+
```sh
85+
cargo install cargo-insta --locked
7686
```
7787

7888
To run the tests:
7989

8090
```sh
81-
cargo test
91+
cargo insta test
8292
```
8393

84-
To ensure the code compiles run:
94+
If the code change is expected to update a snapshot, for example when updating a default
95+
dependency, run the tests with the verify flat and check that the new snapshots are correct, then
96+
accept them.
97+
98+
```sh
99+
cargo insta test --verify
100+
```
101+
102+
#### Ensure the code compiles
85103

86104
```sh
87105
cargo check --all-targets
@@ -99,13 +117,18 @@ To run linting:
99117
just lint
100118
```
101119

102-
Using just to run the tests will start Meilisearch in a Docker container, run the tests, then stop
103-
the container.
120+
To run tests:
104121

105122
```sh
106123
just test
107124
```
108125

126+
To run tests and review snapshots:
127+
128+
```sh
129+
just test-review
130+
```
131+
109132
To see a full list of `just` commands run `just --list`
110133

111134
## Committing your code

justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ fmt:
1919
cargo fmt --all
2020

2121
test:
22+
cargo insta test
23+
24+
test-review:
2225
cargo insta test --review

0 commit comments

Comments
 (0)