Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Infer Local Package During Generation #737

Open
1 of 5 tasks
mkeeler opened this issue Nov 20, 2023 · 1 comment
Open
1 of 5 tasks

Feature Request: Infer Local Package During Generation #737

mkeeler opened this issue Nov 20, 2023 · 1 comment

Comments

@mkeeler
Copy link

mkeeler commented Nov 20, 2023

Description

I have a mockery config like:

with-expecter: true
all: true
recursive: false
dir: "{{.PackageName}}mock"
outpkg: "{{.PackageName}}mock"
mockname: "{{.InterfaceName}}"
packages:
  github.com/mkeeler/repo/path/to/sub/package:

I am placing a .mockery.yaml file into the sub-packages directory to control how that package generates mocks. It would be great if I could omit the packages and have mockery execute on the package within the same directory or if instead the package names could be templated. Something like the following would be nice:

with-expecter: true
all: true
recursive: false
dir: "{{.PackageName}}mock"
outpkg: "{{.PackageName}}mock"
mockname: "{{.InterfaceName}}"
packages:
  {{.PackageFromDir}}:

With that I could define a single configuration and run mockery within different packages to generate the mocks for that package.

I am trying to avoid having a single .mockery.yaml file for the entire repo as different parts of the repo are owned by different teams in my organization.

go list . will output the current directories corresponding Go package so I assume it should be relatively simple to get it programmatically as well.

Mockery Version

2.37.1

Golang Version

1.21

Installation Method

  • Binary Distribution
  • Docker
  • brew
  • go install
  • Other: [specify]

Steps to Reproduce

N/A

Expected Behavior

N/A

Actual Behavior

N/A

@LandonTClipp
Copy link
Collaborator

In theory, this could be done by the Config object looking for go.mod in the working directory and inferring from that. I want to make mockery more friendly to monorepo-style repos, but for now I don't see this particular feature as something that would dramatically improve quality of life.

I can leave it up for consideration. For the audience, vote up on it if you want this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants