mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-28 23:58:19 +00:00
fix: make go-generate now creates working mocks out of the box (#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.
This commit is contained in:
committed by
GitHub
parent
31a5639635
commit
4a921b3d65
@@ -26,16 +26,16 @@ func NewMockStatusUpdater(options ...pegomock.Option) *MockStatusUpdater {
|
||||
func (mock *MockStatusUpdater) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
|
||||
func (mock *MockStatusUpdater) FailHandler() pegomock.FailHandler { return mock.fail }
|
||||
|
||||
func (mock *MockStatusUpdater) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string, result *command.ProjectResult) error {
|
||||
func (mock *MockStatusUpdater) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string, res *command.ProjectResult) error {
|
||||
if mock == nil {
|
||||
panic("mock must not be nil. Use myMock := NewMockStatusUpdater().")
|
||||
}
|
||||
params := []pegomock.Param{ctx, cmdName, status, url, result}
|
||||
pegomockResult := pegomock.GetGenericMockFrom(mock).Invoke("UpdateProject", params, []reflect.Type{reflect.TypeOf((*error)(nil)).Elem()})
|
||||
params := []pegomock.Param{ctx, cmdName, status, url, res}
|
||||
result := pegomock.GetGenericMockFrom(mock).Invoke("UpdateProject", params, []reflect.Type{reflect.TypeOf((*error)(nil)).Elem()})
|
||||
var ret0 error
|
||||
if len(pegomockResult) != 0 {
|
||||
if pegomockResult[0] != nil {
|
||||
ret0 = pegomockResult[0].(error)
|
||||
if len(result) != 0 {
|
||||
if result[0] != nil {
|
||||
ret0 = result[0].(error)
|
||||
}
|
||||
}
|
||||
return ret0
|
||||
@@ -78,8 +78,8 @@ type VerifierMockStatusUpdater struct {
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
func (verifier *VerifierMockStatusUpdater) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string, result *command.ProjectResult) *MockStatusUpdater_UpdateProject_OngoingVerification {
|
||||
params := []pegomock.Param{ctx, cmdName, status, url, result}
|
||||
func (verifier *VerifierMockStatusUpdater) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string, res *command.ProjectResult) *MockStatusUpdater_UpdateProject_OngoingVerification {
|
||||
params := []pegomock.Param{ctx, cmdName, status, url, res}
|
||||
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "UpdateProject", params, verifier.timeout)
|
||||
return &MockStatusUpdater_UpdateProject_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
|
||||
}
|
||||
@@ -90,8 +90,8 @@ type MockStatusUpdater_UpdateProject_OngoingVerification struct {
|
||||
}
|
||||
|
||||
func (c *MockStatusUpdater_UpdateProject_OngoingVerification) GetCapturedArguments() (command.ProjectContext, command.Name, models.CommitStatus, string, *command.ProjectResult) {
|
||||
ctx, cmdName, status, url, result := c.GetAllCapturedArguments()
|
||||
return ctx[len(ctx)-1], cmdName[len(cmdName)-1], status[len(status)-1], url[len(url)-1], result[len(result)-1]
|
||||
ctx, cmdName, status, url, res := c.GetAllCapturedArguments()
|
||||
return ctx[len(ctx)-1], cmdName[len(cmdName)-1], status[len(status)-1], url[len(url)-1], res[len(res)-1]
|
||||
}
|
||||
|
||||
func (c *MockStatusUpdater_UpdateProject_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []command.Name, _param2 []models.CommitStatus, _param3 []string, _param4 []*command.ProjectResult) {
|
||||
|
||||
Reference in New Issue
Block a user