Skip to content

Commit 7827d14

Browse files
authored
Merge pull request #1128 from LandonTClipp/logging_help
Add logs/docs that aid in confusion around auto-generated files
2 parents f5daeff + 0637ada commit 7827d14

5 files changed

Lines changed: 28 additions & 3 deletions

File tree

docs/faq.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@ title: FAQ
55
Frequently Asked Questions
66
===========================
77

8+
error: `interface not found in source`
9+
--------------------------------------
10+
11+
!!! tip "v3.6.0"
12+
13+
Version [`v3.6.0`](https://github.com/vektra/mockery/releases/tag/v3.6.0) of mockery fixed a bug in how files were detected to be auto-generated. Many users may find that mockery is suddenly unable to find mocks after upgrading to `v3.6.0`. Try providing:
14+
15+
```yaml title=""
16+
include-auto-generated: true
17+
```
18+
19+
in your mockery config to see if this resolves the issue.
20+
21+
This log message indicates that an interface was explicitly listed in the mockery config but it was not found in the source. This can happen for a number of reasons:
22+
23+
1. The package name was misspelled
24+
2. The interface name was misspelled
25+
3. The `#!yaml include-auto-generated: false` parameter was set (of which `false` is the default) and the interface lived in an auto-generated file.
26+
27+
Setting `#!yaml log-level: debug` can provide a lot of insight into mockery's decision tree, so we recommend inspecting these logs for further clues into why the interface was not found.
28+
29+
For more details on `include-auto-generated`, visit [the related documentation](include-auto-generated.md).
30+
831
error: `no go files found in root search path`
932
---------------------------------------------
1033

docs/generate-directive.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Description
1+
:octicons-tag-24: v3.6.0
22

33
An alternative way to configure mocks is to use the `#!go //mockery:generate` directive. Mockery parses the doc comments and allows you to override configuration of specific interfaces in the source code. For example:
44

internal/cmd/mockery.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ func (r *RootApp) Run() error {
396396
log.Error().
397397
Str(logging.LogKeyInterface, ifaceName).
398398
Str(logging.LogKeyPackagePath, packagePath).
399-
Msg("interface not found in source")
399+
Str(logging.LogKeyDocsURL, logging.DocsURL("/faq/#error-interface-not-found-in-source")).
400+
Msg("interface not found in source. View the linked documentation for possible reasons why this might occur.")
400401
}
401402
}
402403
if foundMissing {

internal/logging/logging.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
const (
1818
LogKeyBaseDir = "base-dir"
1919
LogKeyDir = "dir"
20+
LogKeyDocsURL = "docs-url"
2021
LogKeyFile = "file"
2122
LogKeyInterface = "interface"
2223
LogKeyImport = "import"

mockery-tools.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION=v3.6.0
1+
VERSION=v3.6.1

0 commit comments

Comments
 (0)