You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: .github/ISSUE_TEMPLATE.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
PLEASE READ
2
2
-------------
3
3
4
-
DO NOT submit tickets without _first_ using the latest version of Golang, clearing your local golang package cache, and re-building mockery using the _latest_Golang version and the _latest_ version of mockery. Please provide evidence this has been done in your issue. Failure to provide this evidence will likely result in your issue being closed.
4
+
DO NOT submit tickets without _first_ using the latest version of Go, clearing your local golang package cache, and re-building mockery using the _latest_Go version and the _latest_ version of mockery. Please provide evidence this has been done in your issue. Failure to provide this evidence will likely result in your issue being closed.
Copy file name to clipboardexpand all lines: docs/configuration.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -81,7 +81,7 @@ Parameter Descriptions
81
81
| [`recursive`](features.md#recursive-package-discovery) | :fontawesome-solid-x: | `#!yaml false` | When set to `true` on a particular package, mockery will recursively search for all sub-packages and inject those packages into the config map. |
| `tags` | :fontawesome-solid-x: | `#!yaml ""` | A space-separated list of additional build tags to load packages. |
84
-
| [`with-expecter`](features.md#expecter-structs) | :fontawesome-solid-x: | `#!yaml true` | Use `with-expecter: True` to generate `EXPECT()` methods for your mocks. This is the preferred way to setup your mocks. |
84
+
| [`with-expecter`](features.md#expecter-structs) | :fontawesome-solid-x: | `#!yaml true` | Use `with-expecter: True` to generate `EXPECT()` methods for your mocks. This is the preferred way to set up your mocks. |
You can use the `showconfig` command to see the config mockery injects. The output of `showconfig` theoretically could be copy-pasted into your yaml file as it is semantically equivalent.
236
+
You can use the `showconfig` command to see the config mockery injects. The output of `showconfig` theoretically could be copy-pasted into your YAML file as it is semantically equivalent.
237
237
238
238
mockery will _not_ recurse into submodules, i.e. any subdirectory that contains a go.mod file. You must specify the submodule as a separate line item in the config if you would like mocks generated for it as well.
239
239
240
240
??? note "performance characteristics"
241
-
The performance when using `#!yaml recursive: true` may be worse than manually specifying all packages statically in the yaml file. This is because of the fact that mockery has to recursively walk the filesystem path that contains the package in question. It may unnecessarily walk down unrelated paths (for example, a Python virtual environment that is in the same path as your package). For this reason, it is recommended _not_ to use `#!yaml recursive: true` if it can be avoided.
241
+
The performance when using `#!yaml recursive: true` may be worse than manually specifying all packages statically in the YAML file. This is because of the fact that mockery has to recursively walk the filesystem path that contains the package in question. It may unnecessarily walk down unrelated paths (for example, a Python virtual environment that is in the same path as your package). For this reason, it is recommended _not_ to use `#!yaml recursive: true` if it can be avoided.
242
242
243
243
### Regex matching
244
244
@@ -334,7 +334,7 @@ Return Value Providers
334
334
335
335
:octicons-tag-24: v2.20.0
336
336
337
-
Return Value Providers can be used one of two ways. You may either define a single function with the exact same signature (number and type of input and return parameters) and pass that as a single value to `Return`, or you may pass multiple values to `Return` (one for each return parameter of the mocked function.) If you are using the second form, for each of the return values of the mocked function, `Return` needs a function which takes the same arguments as the mocked function, and returns one of the return values. For example, if the return argument signature of `passthrough` in the above example was instead `(string, error)` in the interface, `Return` would also need a second function argument to define the error value:
337
+
Return Value Providers can be used one of two ways. You may either define a single function with the exact same signature (number and type of input and return parameters) and pass that as a single value to `Return`, or you may pass multiple values to `Return` (one for each return parameter of the mocked function.) If you are using the second form, for each of the return values of the mocked function, `Return` needs a function which takes the same arguments as the mocked function, and returns one of the return values. For example, if the return argument signature of `passthrough` in the above example was instead `(string, error)` in the interface, `Return` would also need a second function argument to define the error value:
Copy file name to clipboardexpand all lines: docs/index.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ func getFromDB(db DB) string {
25
25
}
26
26
```
27
27
28
-
You can test `getFromDB` by either instantiating a testing database, or you can simply create a mock implementation of `DB` using mockery. Mockery can autogenerate a mock implementation that allows us to define assertions on how the mock was used, what to return, and other useful tidbits. We can add a `//go:generate` directive above our interface:
28
+
You can test `getFromDB` by either instantiating a testing database, or you can simply create a mock implementation of `DB` using mockery. Mockery can automatically generate a mock implementation that allows us to define assertions on how the mock was used, what to return, and other useful tidbits. We can add a `//go:generate` directive above our interface:
Copy file name to clipboardexpand all lines: docs/migrating_to_packages.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Migrating To Packages
3
3
---
4
4
5
-
The [packages](features.md#packages-configuration) feature is a new configuration scheme that aims to simplify and improve a lot of legacy behavior. This will be the only way to generate mocks in v3. These docs outline general principals for migrating to the new scheme.
5
+
The [packages](features.md#packages-configuration) feature is a new configuration scheme that aims to simplify and improve a lot of legacy behavior. This will be the only way to generate mocks in v3. These docs outline general principles for migrating to the new scheme.
6
6
7
7
Background
8
8
----------
@@ -29,7 +29,7 @@ All of the parameters in the config section can be specified at the top level of
29
29
30
30
#### Separate `mocks/` directory
31
31
32
-
Take for example a configuration where you are specifying `all: true` at the top of your repo and you're placing your mocks in a separate `mocks/` directory, mirroring the directory structure of your original repo.
32
+
Take for example a configuration where you are specifying `all: true` at the top of your repo, and you're placing your mocks in a separate `mocks/` directory, mirroring the directory structure of your original repo.
33
33
34
34
```yaml
35
35
testonly: False
@@ -53,7 +53,7 @@ packages:
53
53
recursive: True
54
54
```
55
55
56
-
1. The use of `replaceAll` is a trick that is done to ensure mocks created for `internal` packages can be imported outside of the mock directory. This retains the behavior of the legacy config.
56
+
1. The use of `replaceAll` is a trick that is done to ensure mocks created for `internal` packages can be imported outside the mock directory. This retains the behavior of the legacy config.
57
57
58
58
While the example config provided here is more verbose, that is because we're specifying many non-default values in order to retain strict equivalence for this example. It's recommended to refer to the [configuration parameters](configuration.md#parameter-descriptions) to see the defaults provided.
59
59
@@ -98,7 +98,7 @@ Previously, the recommended way of generating mocks was to call `mockery` once p
98
98
Behavior Changes
99
99
-----------------
100
100
101
-
The legacy behavior iterated over every `.go` file in your project, called [`packages.Load`](https://pkg.go.dev/golang.org/x/tools/go/packages#Load) to parse the syntax tree, and generated mocks for every interface found in the file. The new behavior instead simply grabs the list of packages to load from the config file, or in the case of `#!yaml recursive: True`, walks the filesystem tree to discover the packages that exist (without actually parsing the files). Using this list, it calls `packages.Load` once with the list of packages that were discovered.
101
+
The legacy behavior iterated over every `.go` file in your project, called [`packages.Load`](https://pkg.go.dev/golang.org/x/tools/go/packages#Load) to parse the syntax tree, and generated mocks for every interface found in the file. The new behavior instead simply grabs the list of packages to load from the config file, or in the case of `#!yaml recursive: True`, walks the file-system tree to discover the packages that exist (without actually parsing the files). Using this list, it calls `packages.Load` once with the list of packages that were discovered.
Copy file name to clipboardexpand all lines: docs/notes.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ Additionally, this issue only happens when compiling mockery from source, such a
26
26
Multiple Expectations With Identical Arguments
27
27
-----------------------------------------------
28
28
29
-
There might be instances where you want a mock to return different values on successive calls that provide the same arguments. For example we might want to test this behavior:
29
+
There might be instances where you want a mock to return different values on successive calls that provide the same arguments. For example, we might want to test this behavior:
Note that with proper Golang support in your IDE, all of the available methods are self-documented in auto-completion help contexts.
56
+
Note that with proper Go support in your IDE, all the available methods are self-documented in autocompletion help contexts.
57
57
58
58
Variadic Arguments
59
59
------------------
@@ -113,14 +113,14 @@ Semantic Versioning
113
113
The versioning in this project applies only to the behavior of the mockery binary itself. This project explicitly does not promise a stable internal API, but rather a stable executable. The versioning applies to the following:
114
114
115
115
1. CLI arguments.
116
-
2. Parsing of Golang code. New features in the Golang language will be supported in a backwards-compatible manner, except during major version bumps.
116
+
2. Parsing of Go code. New features in the Go language will be supported in a backwards-compatible manner, except during major version bumps.
117
117
3. Behavior of mock objects. Mock objects can be considered to be part of the public API.
118
118
4. Behavior of mockery given a set of arguments.
119
119
120
120
What the version does _not_ track:
121
121
122
122
1. The interfaces, objects, methods etc. in the vektra/mockery package.
123
-
2. Compatibility of `go get`-ing mockery with new or old versions of Golang.
123
+
2. Compatibility of `go get`-ing mockery with new or old versions of Go.
124
124
125
125
Mocking interfaces in `main`
126
126
----------------------------
@@ -135,4 +135,4 @@ This issue was first highlighted [in this GitHub issue](https://github.com/vektr
135
135
136
136
mockery uses the viper package for configuration mapping and parsing. Viper is set to automatically search for all config variables specified in its config struct. One of the config variables is named `version`, which gets mapped to an environment variable called `MOCKERY_VERSION`. If you set this environment variable, mockery attempts to parse it into the `version` bool config.
137
137
138
-
This is an unintended side-effect of how our config parsing is set up. The solution is to rename your environment variable to something other than `MOCKERY_VERSION`.
138
+
This is an adverse effect of how our config parsing is set up. The solution is to rename your environment variable to something other than `MOCKERY_VERSION`.
Copy file name to clipboardexpand all lines: docs/running.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ packages:
18
18
# Lots more config...
19
19
```
20
20
21
-
From anywhere within your repo, you can simply call `mockery` once and it will find your config either by respecting the `#!yaml config` path you gave it, or by searching upwards from the current working directory.
21
+
From anywhere within your repo, you can simply call `mockery` once, and it will find your config either by respecting the `#!yaml config` path you gave it, or by searching upwards from the current working directory.
0 commit comments