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

feat(mockgen): respect custom function implementations #4

Merged
merged 1 commit into from
Dec 21, 2023

Conversation

au-phiware
Copy link
Collaborator

Prior to this change, a user of mockgen was free to include any function declarations that they wished, but it was possible that they collided with generated functions, leading to a broken build.

This change performs a scan of the existing packages for any colliding function names or functions that already provide the call to mock.Expect. We naively assume that the result of the mock.Expect call is returned from the user defined function. If there is more than one call to a mock.Expect function within a single custom function then we ignore the custom function and generate functions as per normal. If there is a function that collides with a generated function name but does not make a call to a mock.Expect function then the generated function falls back to a more verbose name.

Prior to this change, a user of mockgen was free to include any function
declarations that they wished, but it was possible that they collided
with generated functions, leading to a broken build.

This change performs a scan of the existing packages for any colliding
function names or functions that already provide the call to
mock.Expect.  We naively assume that the result of the mock.Expect call
is returned from the user defined function.  If there is more than one
call to a mock.Expect function within a single custom function then we
ignore the custom function and generate functions as per normal.  If
there is a function that collides with a generated function name but
does not make a call to a mock.Expect function then the generated
function falls back to a more verbose name.
@au-phiware au-phiware merged commit b75a1e6 into main Dec 21, 2023
1 check passed
@au-phiware au-phiware deleted the custom-funcs branch December 21, 2023 22:29
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

Successfully merging this pull request may close these issues.

2 participants