Skip to content

fix: make go-generate now creates working mocks out of the box#3802

Merged
GenPage merged 2 commits intorunatlantis:mainfrom
finnag:fix-go-generate
Oct 6, 2023
Merged

fix: make go-generate now creates working mocks out of the box#3802
GenPage merged 2 commits intorunatlantis:mainfrom
finnag:fix-go-generate

Conversation

@finnag
Copy link
Contributor

@finnag finnag commented Sep 29, 2023

what

Change some function parameter names from "result" to "res" so pegomock creates valid go code automatically.

why

pegomock generates code that among other things contains result := ..., which breaks if result exists as a function parameter. I don't know how this was handled before, I suspect manual editing after running make go-generate?

tests

  • I have tested my changes by make test-all

references

The code generated by pegomock is broken if any of the arguments to the
mocked function are named "result", so they must be named something else.
The mocks now work without further modification after running go-generate.
@finnag finnag requested a review from a team as a code owner September 29, 2023 09:57
@github-actions github-actions bot added the go Pull requests that update Go code label Sep 29, 2023
Copy link
Member

@GenPage GenPage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you

@GenPage GenPage merged commit 4a921b3 into runatlantis:main Oct 6, 2023
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
…lantis#3802)

* Rename arguments in mocked functions from result to res

The code generated by pegomock is broken if any of the arguments to the
mocked function are named "result", so they must be named something else.

* Regenerate all mocks with make go-generate

The mocks now work without further modification after running go-generate.
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
…lantis#3802)

* Rename arguments in mocked functions from result to res

The code generated by pegomock is broken if any of the arguments to the
mocked function are named "result", so they must be named something else.

* Regenerate all mocks with make go-generate

The mocks now work without further modification after running go-generate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants