-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #544 from LandonTClipp/mkdocs
Add more mkdocs documentation, examples etc
- Loading branch information
Showing
6 changed files
with
157 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ mockery.prof | |
dist | ||
.idea | ||
docs/ve | ||
ve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
Getting Started | ||
================ | ||
|
||
Installation | ||
------------- | ||
|
||
### go install | ||
|
||
Supported, but not recommended: [see wiki page](https://github.com/vektra/mockery/wiki/Installation-Methods#go-install) and [related discussions](https://github.com/vektra/mockery/pull/456). | ||
|
||
Alternatively, you can use the go install method to compile the project using your local environment: | ||
|
||
go install github.com/vektra/mockery/v2@latest | ||
|
||
### GitHub Release | ||
|
||
Visit the [releases page](https://github.com/vektra/mockery/releases) to download one of the pre-built binaries for your platform. | ||
|
||
### Docker | ||
|
||
Use the [Docker image](https://hub.docker.com/r/vektra/mockery) | ||
|
||
docker pull vektra/mockery | ||
|
||
Generate all the mocks for your project: | ||
|
||
docker run -v "$PWD":/src -w /src vektra/mockery --all | ||
|
||
### Homebrew | ||
|
||
Install through [brew](https://brew.sh/) | ||
|
||
brew install mockery | ||
brew upgrade mockery | ||
|
||
Configuration | ||
-------------- | ||
|
||
mockery uses [spf13/viper](https://github.com/spf13/viper) under the hood for its configuration parsing. It is bound to three different configuration sources, in order of decreasing precedence: | ||
|
||
1. Command line | ||
2. Environment variables | ||
3. Configuration file | ||
|
||
Copy the recommended basic configuration to a file called `.mockery.yaml` at the top-level of your repo: | ||
|
||
```yaml | ||
all: True | ||
keeptree: True | ||
``` | ||
mockery will search upwards from your current-working-directory up to the root path, so the same configuration should be able to follow you within your project. | ||
Run mockery | ||
------------ | ||
### For all interfaces in project | ||
```bash | ||
$ mockery | ||
09 Feb 23 22:47 CST INF Starting mockery dry-run=false version=v2.18.0 | ||
09 Feb 23 22:47 CST INF Using config: /Users/landonclipp/git/LandonTClipp/mockery/.mockery.yaml dry-run=false version=v2.18.0 | ||
09 Feb 23 22:47 CST INF Walking dry-run=false version=v2.18.0 | ||
09 Feb 23 22:47 CST INF Generating mock dry-run=false interface=A qualified-name=github.com/vektra/mockery/v2/pkg/fixtures version=v2.18.0 | ||
``` | ||
|
||
### Using `go generate` | ||
|
||
`go generate` is often preferred as it give you more targeted generation of specific interfaces. Use `generate` as a directive above the interface you want to generate a mock for. | ||
|
||
``` golang | ||
package example_project | ||
|
||
//go:generate mockery --name Root --all=False | ||
type Root interface { | ||
Foobar(s string) error | ||
} | ||
``` | ||
|
||
Then simply: | ||
|
||
``` bash | ||
$ go generate | ||
09 Feb 23 22:55 CST INF Starting mockery dry-run=false version=v2.18.0 | ||
09 Feb 23 22:55 CST INF Using config: /Users/landonclipp/git/LandonTClipp/mockery/.mockery.yaml dry-run=false version=v2.18.0 | ||
09 Feb 23 22:55 CST INF Walking dry-run=false version=v2.18.0 | ||
09 Feb 23 22:55 CST INF Generating mock dry-run=false interface=Root qualified-name=github.com/vektra/mockery/v2/pkg/fixtures/example_project version=v2.18.0 | ||
``` | ||
|
||
Note that mockery running in `go generate` will still ingest configuration from your top-level `.mockery.yaml` file, so you may have to enable/disable certain configuration parameters from the command line to prevent collisions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
mockery | ||
========= | ||
======== | ||
|
||
Welcome to mockery! This is the initial scaffolding for the documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
site_name: mockery | ||
theme: | ||
name: material | ||
|
||
|
||
palette: | ||
# Palette toggle for light mode | ||
- media: "(prefers-color-scheme: light)" | ||
scheme: default | ||
toggle: | ||
icon: material/brightness-7 | ||
name: Switch to dark mode | ||
# Palette toggle for dark mode | ||
- media: "(prefers-color-scheme: dark)" | ||
scheme: slate | ||
toggle: | ||
icon: material/brightness-4 | ||
name: Switch to light mode | ||
features: | ||
- content.code.copy | ||
markdown_extensions: | ||
- pymdownx.highlight: | ||
anchor_linenums: true | ||
auto_title: true | ||
- pymdownx.superfences |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package example_project | ||
|
||
//go:generate mockery --name GoGenerateExample --all=False | ||
type GoGenerateExample interface { | ||
Foo(s string) error | ||
} |