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

mock generation for non-relative-to-interface dirs #802

Open
1 of 5 tasks
tobby-s opened this issue Aug 11, 2024 · 2 comments · May be fixed by #807
Open
1 of 5 tasks

mock generation for non-relative-to-interface dirs #802

tobby-s opened this issue Aug 11, 2024 · 2 comments · May be fixed by #807
Labels
approved feature Feature request approved for development

Comments

@tobby-s
Copy link

tobby-s commented Aug 11, 2024

Description

when the dir config is specified as not relative to the package (doesn't use {{.InterfaceDir}} template), the generation is relative to the current working directory rather than the project root (or wherever .mockery.yaml is specified).

Mockery Version

2.42.1

Go Version

1.22.3

NOTE: Please upgrade to the latest golang version before submitting tickets!

Installation Method

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

Steps to Reproduce

  1. write an interface in a package (or set .mockery.yaml to mock an interface from an external go module, which is the use-case i'm encountering this issue), have /mocks directory exist in project root
  2. set dir to mocks in .mockery.yaml, e.g.:
with-expecter: true
dir: "mocks"
outpkg: "mocks"
mockname: "{{.InterfaceName}}"
filename: "{{.InterfaceName}}.go"
packages:
  context:
    interfaces:
      Context:
  1. run mockery in project root then cd mocks and run it again

Expected Behavior

the second mockery shouldn't add any new files since config file was not changed between the two runs

Actual Behavior

new mocks are created in mocks/mocks

Proposal

add a new template that indicates the .mockery.yaml location, e.g. {{.ConfigDir}}

@LandonTClipp
Copy link
Collaborator

add a new template that indicates the .mockery.yaml location, e.g. {{.ConfigDir}}

This is a great idea and should be super easy to do. I approve of doing this, but I'm not sure when I'll have the time to get to it. Maybe in the next week or two unless anyone else wants to take it.

@LandonTClipp LandonTClipp added the approved feature Feature request approved for development label Aug 13, 2024
@tobby-s
Copy link
Author

tobby-s commented Aug 17, 2024

#807

do let me know of any other documenatation / tests etc i need to add.

@tobby-s tobby-s linked a pull request Aug 17, 2024 that will close this issue
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved feature Feature request approved for development
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants