runatlantis / atlantis

Terraform Pull Request Automation
https://www.runatlantis.io
Other
7.51k stars 1.02k forks source link

feat: migrate mocks to mockery #4688

Open chenrui333 opened 2 weeks ago

chenrui333 commented 2 weeks ago

fixes #4664

github-actions[bot] commented 2 weeks ago

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

james0209 commented 1 week ago

If switching to Mockery, it's probably worth using the packages configuration scheme instead - the current draft PR implementation is deprecated.

https://vektra.github.io/mockery/latest/migrating_to_packages/

e.g. .mockery.yaml config for a separate mocks directory mirroring the directory structure of your original repo (which I think is better)

with-expecter: True
dir: mocks/{{ replaceAll .InterfaceDirRelative "internal" "internal_" }} 
mockname: "{{.InterfaceName}}"
outpkg: "{{.PackageName}}"
filename: "{{.InterfaceName}}.go"
all: True
packages:
  github.com/runatlantis/atlantis:
    config:
      recursive: True

Or you could have the mocks adjacent to the interface if you wanted: https://vektra.github.io/mockery/latest/migrating_to_packages/#adjacent-to-interface

chenrui333 commented 1 week ago

@james0209 thanks for weighing in here, yeah, I was definitely thinking that I was going with the packages configuration route. :) Any way, let me refine the PR a bit.

chenrui333 commented 1 day ago

todos for this pr: