Skip to content

Commit

Permalink
Merge pull request #528 from LandonTClipp/docs
Browse files Browse the repository at this point in the history
Update documentation
  • Loading branch information
LandonTClipp committed Dec 20, 2022
2 parents 7402646 + 81d4712 commit 78f7ac3
Showing 1 changed file with 43 additions and 32 deletions.
75 changes: 43 additions & 32 deletions README.md
Expand Up @@ -14,6 +14,9 @@ Table of Contents
* [Docker](#docker)
* [Homebrew](#homebrew)
* [go install](#go-install)
- [Configuration](#configuration)
* [Example](#example)
* [Config Search Path](#config-search-path)
- [Examples](#examples)
+ [Simplest case](#simplest-case)
+ [Function type case](#function-type-case)
Expand All @@ -25,10 +28,12 @@ Table of Contents
- [Expecter Interfaces](#expecter-interfaces)
- [Mock constructors](#mock-constructors)
- [Extended Flag Descriptions](#extended-flag-descriptions)
- [Mocking interfaces in `main`](#mocking-interfaces-in-main)
- [Configuration](#configuration)
* [Example](#example)
- [Mocking interfaces in `main`](#mocking-interfaces-in--main-)
- [Semantic Versioning](#semantic-versioning)
- [Development Efforts](#development-efforts)
* [v1](#v1)
* [v2](#v2)
* [v3](#v3)
- [Stargazers](#stargazers)


Expand Down Expand Up @@ -64,6 +69,41 @@ Alternatively, you can use the go install method to compile the project using yo

go install github.com/vektra/mockery/v2@latest

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

### Example

$ export MOCKERY_STRUCTNAME=config_from_env
$ echo $MOCKERY_STRUCTNAME
config_from_env
$ grep structname .mockery.yaml
structname: config_from_file
$ ./mockery showconfig --structname config_from_cli | grep structname
Using config file: /home/ltclipp/git/vektra/mockery/.mockery.yaml
structname: config_from_cli
$ ./mockery showconfig | grep structname
Using config file: /home/ltclipp/git/vektra/mockery/.mockery.yaml
structname: config_from_env
$ unset MOCKERY_STRUCTNAME
$ ./mockery showconfig | grep structname
Using config file: /home/ltclipp/git/vektra/mockery/.mockery.yaml
structname: config_from_file

By default, it searches the current working directory for a file named `.mockery.[extension]` where [extension] is any of the [recognized extensions](https://pkg.go.dev/github.com/spf13/viper@v1.7.0?tab=doc#pkg-variables).

### Config Search Path

New in [v2.16.0](https://github.com/vektra/mockery/pull/527)

Mockery will iteratively search every directory from the current working directory up to the root path for a `.mockery.yaml` file, if one is not explicitly provided.

Examples
--------

Expand Down Expand Up @@ -376,35 +416,6 @@ Mocking interfaces in `main`
When your interfaces are in the main package, you should supply the `--inpackage` flag.
This will generate mocks in the same package as the target code, avoiding import issues.

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

### Example

$ export MOCKERY_STRUCTNAME=config_from_env
$ echo $MOCKERY_STRUCTNAME
config_from_env
$ grep structname .mockery.yaml
structname: config_from_file
$ ./mockery showconfig --structname config_from_cli | grep structname
Using config file: /home/ltclipp/git/vektra/mockery/.mockery.yaml
structname: config_from_cli
$ ./mockery showconfig | grep structname
Using config file: /home/ltclipp/git/vektra/mockery/.mockery.yaml
structname: config_from_env
$ unset MOCKERY_STRUCTNAME
$ ./mockery showconfig | grep structname
Using config file: /home/ltclipp/git/vektra/mockery/.mockery.yaml
structname: config_from_file

By default, it searches the current working directory for a file named `.mockery.[extension]` where [extension] is any of the [recognized extensions](https://pkg.go.dev/github.com/spf13/viper@v1.7.0?tab=doc#pkg-variables).

Semantic Versioning
-------------------

Expand Down

0 comments on commit 78f7ac3

Please sign in to comment.