vektra / mockery

A mock code autogenerator for Go
https://vektra.github.io/mockery/
BSD 3-Clause "New" or "Revised" License
6.14k stars 412 forks source link

Recursive mode fails when the root package doesn't contain go files #837

Closed sonalys closed 1 week ago

sonalys commented 1 week ago

Description

A simple example of this issue would be the following:

- internal
| - application
| | - app.go
| - api
| | - api.go

If I run with recursive mode for internal folder, I get the error:

ERR package contains no go files error="no go files found in root search path" documentation=https://vektra.github.io/mockery/v2.45/notes/#error-no-go-files-found-in-root-search-path dry-run=false package-path=module/internal version=v2.45.1

Mockery Version

2.45

with-expecter: True
dir: mocks/{{ replaceAll .InterfaceDirRelative "internal" "internal_" }} 
mockname: "{{.InterfaceName}}"
outpkg: "{{.PackageName}}"
filename: "{{.InterfaceName}}.gen.go"
all: True
packages:
  module/internal:
    config:
      recursive: true

Go Version

1.23.2

Installation Method

Expected Behavior

For mockery to discover the sub-packages and generate mock for them

Actual Behavior

mockery fails, since the initial package doesn't contain any Go files.

LandonTClipp commented 1 week ago

Yes this is known and it's not something we can fix. The documentation mockery provides you in this log message explains why.