diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go index bfe09983ef..bead7dffb6 100644 --- a/server/controllers/events/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -1068,6 +1068,7 @@ func setupE2E(t *testing.T, repoDir string, opt setupOption) (events_controllers parallelPoolSize := 1 silenceNoProjects := false + statusUpdater := runtimemocks.NewMockStatusUpdater() commitStatusUpdater := mocks.NewMockCommitStatusUpdater() asyncTfExec := runtimemocks.NewMockAsyncTFExec() @@ -1143,7 +1144,7 @@ func setupE2E(t *testing.T, repoDir string, opt setupOption) (events_controllers PlanStepRunner: runtime.NewPlanStepRunner( terraformClient, defaultTFVersion, - commitStatusUpdater, + statusUpdater, asyncTfExec, ), ShowStepRunner: showStepRunner, diff --git a/server/core/runtime/apply_step_runner.go b/server/core/runtime/apply_step_runner.go index a73c82e9f3..eb1633eea0 100644 --- a/server/core/runtime/apply_step_runner.go +++ b/server/core/runtime/apply_step_runner.go @@ -126,7 +126,7 @@ func (a *ApplyStepRunner) runRemoteApply( // updateStatusF will update the commit status and log any error. updateStatusF := func(status models.CommitStatus, url string) { - if err := a.CommitStatusUpdater.UpdateProject(ctx, command.Apply, status, url); err != nil { + if err := a.CommitStatusUpdater.UpdateProject(ctx, command.Apply, status, url, nil); err != nil { ctx.Log.Err("unable to update status: %s", err) } } diff --git a/server/core/runtime/apply_step_runner_test.go b/server/core/runtime/apply_step_runner_test.go index 65601680c9..5b0a4b8c92 100644 --- a/server/core/runtime/apply_step_runner_test.go +++ b/server/core/runtime/apply_step_runner_test.go @@ -12,11 +12,11 @@ import ( . "github.com/petergtz/pegomock" "github.com/pkg/errors" "github.com/runatlantis/atlantis/server/core/runtime" + runtimemocks "github.com/runatlantis/atlantis/server/core/runtime/mocks" runtimemodels "github.com/runatlantis/atlantis/server/core/runtime/models" "github.com/runatlantis/atlantis/server/core/terraform/mocks" matchers2 "github.com/runatlantis/atlantis/server/core/terraform/mocks/matchers" "github.com/runatlantis/atlantis/server/events/command" - mocks2 "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/mocks/matchers" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/logging" @@ -241,7 +241,7 @@ Plan: 0 to add, 0 to change, 1 to destroy.` RegisterMockTestingT(t) tfOut := fmt.Sprintf(preConfirmOutFmt, planFileContents) + postConfirmOut tfExec := &remoteApplyMock{LinesToSend: tfOut, DoneCh: make(chan bool)} - updater := mocks2.NewMockCommitStatusUpdater() + updater := runtimemocks.NewMockStatusUpdater() o := runtime.ApplyStepRunner{ AsyncTFExec: tfExec, CommitStatusUpdater: updater, @@ -273,8 +273,8 @@ Apply complete! Resources: 0 added, 0 changed, 1 destroyed. // Check that the status was updated with the run url. runURL := "https://app.terraform.io/app/lkysow-enterprises/atlantis-tfe-test-dir2/runs/run-PiDsRYKGcerTttV2" - updater.VerifyWasCalledOnce().UpdateProject(ctx, command.Apply, models.PendingCommitStatus, runURL) - updater.VerifyWasCalledOnce().UpdateProject(ctx, command.Apply, models.SuccessCommitStatus, runURL) + updater.VerifyWasCalledOnce().UpdateProject(ctx, command.Apply, models.PendingCommitStatus, runURL, nil) + updater.VerifyWasCalledOnce().UpdateProject(ctx, command.Apply, models.SuccessCommitStatus, runURL, nil) } // Test that if the plan is different, we error out. @@ -304,7 +304,7 @@ Plan: 0 to add, 0 to change, 1 to destroy.` } o := runtime.ApplyStepRunner{ AsyncTFExec: tfExec, - CommitStatusUpdater: mocks2.NewMockCommitStatusUpdater(), + CommitStatusUpdater: runtimemocks.NewMockStatusUpdater(), } tfVersion, _ := version.NewVersion("0.11.0") diff --git a/server/core/runtime/mocks/matchers/command_name.go b/server/core/runtime/mocks/matchers/command_name.go new file mode 100644 index 0000000000..9dcc26d1e8 --- /dev/null +++ b/server/core/runtime/mocks/matchers/command_name.go @@ -0,0 +1,33 @@ +// Code generated by pegomock. DO NOT EDIT. +package matchers + +import ( + "github.com/petergtz/pegomock" + "reflect" + + command "github.com/runatlantis/atlantis/server/events/command" +) + +func AnyCommandName() command.Name { + pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(command.Name))(nil)).Elem())) + var nullValue command.Name + return nullValue +} + +func EqCommandName(value command.Name) command.Name { + pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value}) + var nullValue command.Name + return nullValue +} + +func NotEqCommandName(value command.Name) command.Name { + pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value}) + var nullValue command.Name + return nullValue +} + +func CommandNameThat(matcher pegomock.ArgumentMatcher) command.Name { + pegomock.RegisterMatcher(matcher) + var nullValue command.Name + return nullValue +} diff --git a/server/core/runtime/mocks/matchers/models_commitstatus.go b/server/core/runtime/mocks/matchers/models_commitstatus.go new file mode 100644 index 0000000000..1e10ed7823 --- /dev/null +++ b/server/core/runtime/mocks/matchers/models_commitstatus.go @@ -0,0 +1,33 @@ +// Code generated by pegomock. DO NOT EDIT. +package matchers + +import ( + "github.com/petergtz/pegomock" + "reflect" + + models "github.com/runatlantis/atlantis/server/events/models" +) + +func AnyModelsCommitStatus() models.CommitStatus { + pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(models.CommitStatus))(nil)).Elem())) + var nullValue models.CommitStatus + return nullValue +} + +func EqModelsCommitStatus(value models.CommitStatus) models.CommitStatus { + pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value}) + var nullValue models.CommitStatus + return nullValue +} + +func NotEqModelsCommitStatus(value models.CommitStatus) models.CommitStatus { + pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value}) + var nullValue models.CommitStatus + return nullValue +} + +func ModelsCommitStatusThat(matcher pegomock.ArgumentMatcher) models.CommitStatus { + pegomock.RegisterMatcher(matcher) + var nullValue models.CommitStatus + return nullValue +} diff --git a/server/core/runtime/mocks/matchers/ptr_to_command_projectresult.go b/server/core/runtime/mocks/matchers/ptr_to_command_projectresult.go new file mode 100644 index 0000000000..a3f5a7d10e --- /dev/null +++ b/server/core/runtime/mocks/matchers/ptr_to_command_projectresult.go @@ -0,0 +1,33 @@ +// Code generated by pegomock. DO NOT EDIT. +package matchers + +import ( + "github.com/petergtz/pegomock" + "reflect" + + command "github.com/runatlantis/atlantis/server/events/command" +) + +func AnyPtrToCommandProjectResult() *command.ProjectResult { + pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(*command.ProjectResult))(nil)).Elem())) + var nullValue *command.ProjectResult + return nullValue +} + +func EqPtrToCommandProjectResult(value *command.ProjectResult) *command.ProjectResult { + pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value}) + var nullValue *command.ProjectResult + return nullValue +} + +func NotEqPtrToCommandProjectResult(value *command.ProjectResult) *command.ProjectResult { + pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value}) + var nullValue *command.ProjectResult + return nullValue +} + +func PtrToCommandProjectResultThat(matcher pegomock.ArgumentMatcher) *command.ProjectResult { + pegomock.RegisterMatcher(matcher) + var nullValue *command.ProjectResult + return nullValue +} diff --git a/server/core/runtime/mocks/mock_status_updater.go b/server/core/runtime/mocks/mock_status_updater.go new file mode 100644 index 0000000000..a57b7a0232 --- /dev/null +++ b/server/core/runtime/mocks/mock_status_updater.go @@ -0,0 +1,122 @@ +// Code generated by pegomock. DO NOT EDIT. +// Source: github.com/runatlantis/atlantis/server/core/runtime (interfaces: StatusUpdater) + +package mocks + +import ( + pegomock "github.com/petergtz/pegomock" + command "github.com/runatlantis/atlantis/server/events/command" + models "github.com/runatlantis/atlantis/server/events/models" + "reflect" + "time" +) + +type MockStatusUpdater struct { + fail func(message string, callerSkip ...int) +} + +func NewMockStatusUpdater(options ...pegomock.Option) *MockStatusUpdater { + mock := &MockStatusUpdater{} + for _, option := range options { + option.Apply(mock) + } + return mock +} + +func (mock *MockStatusUpdater) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh } +func (mock *MockStatusUpdater) FailHandler() pegomock.FailHandler { return mock.fail } + +func (mock *MockStatusUpdater) UpdateProject(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus, _param3 string, _param4 *command.ProjectResult) error { + if mock == nil { + panic("mock must not be nil. Use myMock := NewMockStatusUpdater().") + } + params := []pegomock.Param{_param0, _param1, _param2, _param3, _param4} + result := pegomock.GetGenericMockFrom(mock).Invoke("UpdateProject", params, []reflect.Type{reflect.TypeOf((*error)(nil)).Elem()}) + var ret0 error + if len(result) != 0 { + if result[0] != nil { + ret0 = result[0].(error) + } + } + return ret0 +} + +func (mock *MockStatusUpdater) VerifyWasCalledOnce() *VerifierMockStatusUpdater { + return &VerifierMockStatusUpdater{ + mock: mock, + invocationCountMatcher: pegomock.Times(1), + } +} + +func (mock *MockStatusUpdater) VerifyWasCalled(invocationCountMatcher pegomock.InvocationCountMatcher) *VerifierMockStatusUpdater { + return &VerifierMockStatusUpdater{ + mock: mock, + invocationCountMatcher: invocationCountMatcher, + } +} + +func (mock *MockStatusUpdater) VerifyWasCalledInOrder(invocationCountMatcher pegomock.InvocationCountMatcher, inOrderContext *pegomock.InOrderContext) *VerifierMockStatusUpdater { + return &VerifierMockStatusUpdater{ + mock: mock, + invocationCountMatcher: invocationCountMatcher, + inOrderContext: inOrderContext, + } +} + +func (mock *MockStatusUpdater) VerifyWasCalledEventually(invocationCountMatcher pegomock.InvocationCountMatcher, timeout time.Duration) *VerifierMockStatusUpdater { + return &VerifierMockStatusUpdater{ + mock: mock, + invocationCountMatcher: invocationCountMatcher, + timeout: timeout, + } +} + +type VerifierMockStatusUpdater struct { + mock *MockStatusUpdater + invocationCountMatcher pegomock.InvocationCountMatcher + inOrderContext *pegomock.InOrderContext + timeout time.Duration +} + +func (verifier *VerifierMockStatusUpdater) UpdateProject(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus, _param3 string, _param4 *command.ProjectResult) *MockStatusUpdater_UpdateProject_OngoingVerification { + params := []pegomock.Param{_param0, _param1, _param2, _param3, _param4} + methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "UpdateProject", params, verifier.timeout) + return &MockStatusUpdater_UpdateProject_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} +} + +type MockStatusUpdater_UpdateProject_OngoingVerification struct { + mock *MockStatusUpdater + methodInvocations []pegomock.MethodInvocation +} + +func (c *MockStatusUpdater_UpdateProject_OngoingVerification) GetCapturedArguments() (command.ProjectContext, command.Name, models.CommitStatus, string, *command.ProjectResult) { + _param0, _param1, _param2, _param3, _param4 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1], _param3[len(_param3)-1], _param4[len(_param4)-1] +} + +func (c *MockStatusUpdater_UpdateProject_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []command.Name, _param2 []models.CommitStatus, _param3 []string, _param4 []*command.ProjectResult) { + params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) + if len(params) > 0 { + _param0 = make([]command.ProjectContext, len(c.methodInvocations)) + for u, param := range params[0] { + _param0[u] = param.(command.ProjectContext) + } + _param1 = make([]command.Name, len(c.methodInvocations)) + for u, param := range params[1] { + _param1[u] = param.(command.Name) + } + _param2 = make([]models.CommitStatus, len(c.methodInvocations)) + for u, param := range params[2] { + _param2[u] = param.(models.CommitStatus) + } + _param3 = make([]string, len(c.methodInvocations)) + for u, param := range params[3] { + _param3[u] = param.(string) + } + _param4 = make([]*command.ProjectResult, len(c.methodInvocations)) + for u, param := range params[4] { + _param4[u] = param.(*command.ProjectResult) + } + } + return +} diff --git a/server/core/runtime/plan_step_runner.go b/server/core/runtime/plan_step_runner.go index f94932758a..6bc312696c 100644 --- a/server/core/runtime/plan_step_runner.go +++ b/server/core/runtime/plan_step_runner.go @@ -198,7 +198,7 @@ func (p *planStepRunner) runRemotePlan( // updateStatusF will update the commit status and log any error. updateStatusF := func(status models.CommitStatus, url string) { - if err := p.CommitStatusUpdater.UpdateProject(ctx, command.Plan, status, url); err != nil { + if err := p.CommitStatusUpdater.UpdateProject(ctx, command.Plan, status, url, nil); err != nil { ctx.Log.Err("unable to update status: %s", err) } } diff --git a/server/core/runtime/plan_step_runner_test.go b/server/core/runtime/plan_step_runner_test.go index 5e46633935..5a133511f1 100644 --- a/server/core/runtime/plan_step_runner_test.go +++ b/server/core/runtime/plan_step_runner_test.go @@ -8,16 +8,14 @@ import ( "testing" "github.com/hashicorp/go-version" - runtimemocks "github.com/runatlantis/atlantis/server/core/runtime/mocks" - "github.com/runatlantis/atlantis/server/events/command" - eventsmocks "github.com/runatlantis/atlantis/server/events/mocks" - . "github.com/petergtz/pegomock" "github.com/pkg/errors" "github.com/runatlantis/atlantis/server/core/runtime" + runtimemocks "github.com/runatlantis/atlantis/server/core/runtime/mocks" runtimemodels "github.com/runatlantis/atlantis/server/core/runtime/models" "github.com/runatlantis/atlantis/server/core/terraform/mocks" matchers2 "github.com/runatlantis/atlantis/server/core/terraform/mocks/matchers" + "github.com/runatlantis/atlantis/server/events/command" "github.com/runatlantis/atlantis/server/events/mocks/matchers" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/logging" @@ -29,7 +27,7 @@ func TestRun_AddsEnvVarFile(t *testing.T) { // Test that if env/workspace.tfvars file exists we use -var-file option. RegisterMockTestingT(t) terraform := mocks.NewMockClient() - commitStatusUpdater := eventsmocks.NewMockCommitStatusUpdater() + commitStatusUpdater := runtimemocks.NewMockStatusUpdater() asyncTfExec := runtimemocks.NewMockAsyncTFExec() // Create the env/workspace.tfvars file. @@ -98,7 +96,7 @@ func TestRun_UsesDiffPathForProject(t *testing.T) { // file. RegisterMockTestingT(t) terraform := mocks.NewMockClient() - commitStatusUpdater := eventsmocks.NewMockCommitStatusUpdater() + commitStatusUpdater := runtimemocks.NewMockStatusUpdater() asyncTfExec := runtimemocks.NewMockAsyncTFExec() tfVersion, _ := version.NewVersion("0.10.0") logger := logging.NewNoopLogger(t) @@ -178,7 +176,7 @@ Terraform will perform the following actions: ` RegisterMockTestingT(t) terraform := mocks.NewMockClient() - commitStatusUpdater := eventsmocks.NewMockCommitStatusUpdater() + commitStatusUpdater := runtimemocks.NewMockStatusUpdater() asyncTfExec := runtimemocks.NewMockAsyncTFExec() tfVersion, _ := version.NewVersion("0.10.0") s := runtime.NewPlanStepRunner(terraform, tfVersion, commitStatusUpdater, asyncTfExec) @@ -229,7 +227,7 @@ Terraform will perform the following actions: func TestRun_OutputOnErr(t *testing.T) { RegisterMockTestingT(t) terraform := mocks.NewMockClient() - commitStatusUpdater := eventsmocks.NewMockCommitStatusUpdater() + commitStatusUpdater := runtimemocks.NewMockStatusUpdater() asyncTfExec := runtimemocks.NewMockAsyncTFExec() tfVersion, _ := version.NewVersion("0.10.0") s := runtime.NewPlanStepRunner(terraform, tfVersion, commitStatusUpdater, asyncTfExec) @@ -294,7 +292,7 @@ func TestRun_NoOptionalVarsIn012(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { terraform := mocks.NewMockClient() - commitStatusUpdater := eventsmocks.NewMockCommitStatusUpdater() + commitStatusUpdater := runtimemocks.NewMockStatusUpdater() asyncTfExec := runtimemocks.NewMockAsyncTFExec() When(terraform.RunCommandWithVersion( matchers.AnyCommandProjectContext(), @@ -392,7 +390,7 @@ locally at this time. } RegisterMockTestingT(t) terraform := mocks.NewMockClient() - commitStatusUpdater := eventsmocks.NewMockCommitStatusUpdater() + commitStatusUpdater := runtimemocks.NewMockStatusUpdater() tfVersion, _ := version.NewVersion(c.tfVersion) asyncTf := &remotePlanMock{} s := runtime.NewPlanStepRunner(terraform, tfVersion, commitStatusUpdater, asyncTf) @@ -471,8 +469,8 @@ Plan: 0 to add, 0 to change, 1 to destroy.`), "expect plan success") // Ensure that the status was updated with the runURL. runURL := "https://app.terraform.io/app/lkysow-enterprises/atlantis-tfe-test/runs/run-is4oVvJfrkud1KvE" - commitStatusUpdater.VerifyWasCalledOnce().UpdateProject(ctx, command.Plan, models.PendingCommitStatus, runURL) - commitStatusUpdater.VerifyWasCalledOnce().UpdateProject(ctx, command.Plan, models.SuccessCommitStatus, runURL) + commitStatusUpdater.VerifyWasCalledOnce().UpdateProject(ctx, command.Plan, models.PendingCommitStatus, runURL, nil) + commitStatusUpdater.VerifyWasCalledOnce().UpdateProject(ctx, command.Plan, models.SuccessCommitStatus, runURL, nil) }) } } diff --git a/server/core/runtime/runtime.go b/server/core/runtime/runtime.go index 63e2fa427a..7cbfbd2309 100644 --- a/server/core/runtime/runtime.go +++ b/server/core/runtime/runtime.go @@ -48,8 +48,10 @@ type AsyncTFExec interface { // StatusUpdater brings the interface from CommitStatusUpdater into this package // without causing circular imports. +// +//go:generate pegomock generate -m --package mocks -o mocks/mock_status_updater.go StatusUpdater type StatusUpdater interface { - UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) error + UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string, result *command.ProjectResult) error } // Runner mirrors events.StepRunner as a way to bring it into this package diff --git a/server/events/command_runner_internal_test.go b/server/events/command_runner_internal_test.go index 763e29abf0..d16e6def52 100644 --- a/server/events/command_runner_internal_test.go +++ b/server/events/command_runner_internal_test.go @@ -171,7 +171,7 @@ func (m *MockCSU) UpdateCombined(repo models.Repo, pull models.PullRequest, stat return nil } -func (m *MockCSU) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) error { +func (m *MockCSU) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string, result *command.ProjectResult) error { return nil } diff --git a/server/events/commit_status_updater.go b/server/events/commit_status_updater.go index 1d9a149e35..794fe1d36f 100644 --- a/server/events/commit_status_updater.go +++ b/server/events/commit_status_updater.go @@ -16,6 +16,7 @@ package events import ( "fmt" + "github.com/runatlantis/atlantis/server/core/runtime" "github.com/runatlantis/atlantis/server/events/command" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/events/vcs" @@ -34,9 +35,6 @@ type CommitStatusUpdater interface { // UpdateCombinedCount updates the combined status to reflect the // numSuccess out of numTotal. UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, cmdName command.Name, numSuccess int, numTotal int) error - // UpdateProject sets the commit status for the project represented by - // ctx. - UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) error UpdatePreWorkflowHook(pull models.PullRequest, status models.CommitStatus, hookDescription string, runtimeDescription string, url string) error UpdatePostWorkflowHook(pull models.PullRequest, status models.CommitStatus, hookDescription string, runtimeDescription string, url string) error @@ -49,19 +47,22 @@ type DefaultCommitStatusUpdater struct { StatusName string } +// ensure DefaultCommitStatusUpdater implements runtime.StatusUpdater interface +// cause runtime.StatusUpdater is extracted for resolving circular dependency +var _ runtime.StatusUpdater = (*DefaultCommitStatusUpdater)(nil) + func (d *DefaultCommitStatusUpdater) UpdateCombined(repo models.Repo, pull models.PullRequest, status models.CommitStatus, cmdName command.Name) error { src := fmt.Sprintf("%s/%s", d.StatusName, cmdName.String()) var descripWords string switch status { case models.PendingCommitStatus: - descripWords = "in progress..." + descripWords = genProjectStatusDescription(cmdName.String(), "in progress...") case models.FailedCommitStatus: - descripWords = "failed." + descripWords = genProjectStatusDescription(cmdName.String(), "failed.") case models.SuccessCommitStatus: - descripWords = "succeeded." + descripWords = genProjectStatusDescription(cmdName.String(), "succeeded.") } - descrip := fmt.Sprintf("%s %s", cases.Title(language.English).String(cmdName.String()), descripWords) - return d.Client.UpdateStatus(repo, pull, status, src, descrip, "") + return d.Client.UpdateStatus(repo, pull, status, src, descripWords, "") } func (d *DefaultCommitStatusUpdater) UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, cmdName command.Name, numSuccess int, numTotal int) error { @@ -80,7 +81,7 @@ func (d *DefaultCommitStatusUpdater) UpdateCombinedCount(repo models.Repo, pull return d.Client.UpdateStatus(repo, pull, status, src, fmt.Sprintf("%d/%d projects %s successfully.", numSuccess, numTotal, cmdVerb), "") } -func (d *DefaultCommitStatusUpdater) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) error { +func (d *DefaultCommitStatusUpdater) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string, result *command.ProjectResult) error { projectID := ctx.ProjectName if projectID == "" { projectID = fmt.Sprintf("%s/%s", ctx.RepoRelDir, ctx.Workspace) @@ -89,15 +90,21 @@ func (d *DefaultCommitStatusUpdater) UpdateProject(ctx command.ProjectContext, c var descripWords string switch status { case models.PendingCommitStatus: - descripWords = "in progress..." + descripWords = genProjectStatusDescription(cmdName.String(), "in progress...") case models.FailedCommitStatus: - descripWords = "failed." + descripWords = genProjectStatusDescription(cmdName.String(), "failed.") case models.SuccessCommitStatus: - descripWords = "succeeded." + if result != nil && result.PlanSuccess != nil { + descripWords = result.PlanSuccess.Summary() + } else { + descripWords = genProjectStatusDescription(cmdName.String(), "succeeded.") + } } + return d.Client.UpdateStatus(ctx.BaseRepo, ctx.Pull, status, src, descripWords, url) +} - descrip := fmt.Sprintf("%s %s", cases.Title(language.English).String(cmdName.String()), descripWords) - return d.Client.UpdateStatus(ctx.BaseRepo, ctx.Pull, status, src, descrip, url) +func genProjectStatusDescription(cmdName, description string) string { + return fmt.Sprintf("%s %s", cases.Title(language.English).String(cmdName), description) } func (d *DefaultCommitStatusUpdater) UpdatePreWorkflowHook(pull models.PullRequest, status models.CommitStatus, hookDescription string, runtimeDescription string, url string) error { diff --git a/server/events/commit_status_updater_test.go b/server/events/commit_status_updater_test.go index 3d80d4056e..9ccc34fb58 100644 --- a/server/events/commit_status_updater_test.go +++ b/server/events/commit_status_updater_test.go @@ -175,10 +175,7 @@ func TestDefaultCommitStatusUpdater_UpdateProjectSrc(t *testing.T) { ProjectName: c.projectName, RepoRelDir: c.repoRelDir, Workspace: c.workspace, - }, - command.Plan, - models.PendingCommitStatus, - "url") + }, command.Plan, models.PendingCommitStatus, "url", nil) Ok(t, err) client.VerifyWasCalledOnce().UpdateStatus(models.Repo{}, models.PullRequest{}, models.PendingCommitStatus, c.expSrc, "Plan in progress...", "url") }) @@ -191,37 +188,46 @@ func TestDefaultCommitStatusUpdater_UpdateProject(t *testing.T) { cases := []struct { status models.CommitStatus cmd command.Name + result *command.ProjectResult expDescrip string }{ { - models.PendingCommitStatus, - command.Plan, - "Plan in progress...", + status: models.PendingCommitStatus, + cmd: command.Plan, + expDescrip: "Plan in progress...", }, { - models.FailedCommitStatus, - command.Plan, - "Plan failed.", + status: models.FailedCommitStatus, + cmd: command.Plan, + expDescrip: "Plan failed.", }, { - models.SuccessCommitStatus, - command.Plan, - "Plan succeeded.", + status: models.SuccessCommitStatus, + cmd: command.Plan, + result: &command.ProjectResult{ + PlanSuccess: &models.PlanSuccess{ + TerraformOutput: "aaa\nPlan: 1 to add, 2 to change, 3 to destroy.\nbbb", + }, + }, + expDescrip: "Plan: 1 to add, 2 to change, 3 to destroy.", }, { - models.PendingCommitStatus, - command.Apply, - "Apply in progress...", + status: models.PendingCommitStatus, + cmd: command.Apply, + expDescrip: "Apply in progress...", }, { - models.FailedCommitStatus, - command.Apply, - "Apply failed.", + status: models.FailedCommitStatus, + cmd: command.Apply, + expDescrip: "Apply failed.", }, { - models.SuccessCommitStatus, - command.Apply, - "Apply succeeded.", + status: models.SuccessCommitStatus, + cmd: command.Apply, + result: &command.ProjectResult{ + ApplySuccess: "success", + }, + expDescrip: "Apply succeeded.", }, } @@ -232,10 +238,7 @@ func TestDefaultCommitStatusUpdater_UpdateProject(t *testing.T) { err := s.UpdateProject(command.ProjectContext{ RepoRelDir: ".", Workspace: "default", - }, - c.cmd, - c.status, - "url") + }, c.cmd, c.status, "url", c.result) Ok(t, err) client.VerifyWasCalledOnce().UpdateStatus(models.Repo{}, models.PullRequest{}, c.status, fmt.Sprintf("atlantis/%s: ./default", c.cmd.String()), c.expDescrip, "url") }) @@ -250,10 +253,7 @@ func TestDefaultCommitStatusUpdater_UpdateProjectCustomStatusName(t *testing.T) err := s.UpdateProject(command.ProjectContext{ RepoRelDir: ".", Workspace: "default", - }, - command.Apply, - models.SuccessCommitStatus, - "url") + }, command.Apply, models.SuccessCommitStatus, "url", nil) Ok(t, err) client.VerifyWasCalledOnce().UpdateStatus(models.Repo{}, models.PullRequest{}, models.SuccessCommitStatus, "custom/apply: ./default", "Apply succeeded.", "url") diff --git a/server/events/mocks/matchers/ptr_to_command_projectresult.go b/server/events/mocks/matchers/ptr_to_command_projectresult.go new file mode 100644 index 0000000000..a3f5a7d10e --- /dev/null +++ b/server/events/mocks/matchers/ptr_to_command_projectresult.go @@ -0,0 +1,33 @@ +// Code generated by pegomock. DO NOT EDIT. +package matchers + +import ( + "github.com/petergtz/pegomock" + "reflect" + + command "github.com/runatlantis/atlantis/server/events/command" +) + +func AnyPtrToCommandProjectResult() *command.ProjectResult { + pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(*command.ProjectResult))(nil)).Elem())) + var nullValue *command.ProjectResult + return nullValue +} + +func EqPtrToCommandProjectResult(value *command.ProjectResult) *command.ProjectResult { + pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value}) + var nullValue *command.ProjectResult + return nullValue +} + +func NotEqPtrToCommandProjectResult(value *command.ProjectResult) *command.ProjectResult { + pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value}) + var nullValue *command.ProjectResult + return nullValue +} + +func PtrToCommandProjectResultThat(matcher pegomock.ArgumentMatcher) *command.ProjectResult { + pegomock.RegisterMatcher(matcher) + var nullValue *command.ProjectResult + return nullValue +} diff --git a/server/events/mocks/mock_commit_status_updater.go b/server/events/mocks/mock_commit_status_updater.go index 71333d3ce6..d38a52503c 100644 --- a/server/events/mocks/mock_commit_status_updater.go +++ b/server/events/mocks/mock_commit_status_updater.go @@ -86,21 +86,6 @@ func (mock *MockCommitStatusUpdater) UpdatePreWorkflowHook(_param0 models.PullRe return ret0 } -func (mock *MockCommitStatusUpdater) UpdateProject(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus, _param3 string) error { - if mock == nil { - panic("mock must not be nil. Use myMock := NewMockCommitStatusUpdater().") - } - params := []pegomock.Param{_param0, _param1, _param2, _param3} - result := pegomock.GetGenericMockFrom(mock).Invoke("UpdateProject", params, []reflect.Type{reflect.TypeOf((*error)(nil)).Elem()}) - var ret0 error - if len(result) != 0 { - if result[0] != nil { - ret0 = result[0].(error) - } - } - return ret0 -} - func (mock *MockCommitStatusUpdater) VerifyWasCalledOnce() *VerifierMockCommitStatusUpdater { return &VerifierMockCommitStatusUpdater{ mock: mock, @@ -309,42 +294,3 @@ func (c *MockCommitStatusUpdater_UpdatePreWorkflowHook_OngoingVerification) GetA } return } - -func (verifier *VerifierMockCommitStatusUpdater) UpdateProject(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus, _param3 string) *MockCommitStatusUpdater_UpdateProject_OngoingVerification { - params := []pegomock.Param{_param0, _param1, _param2, _param3} - methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "UpdateProject", params, verifier.timeout) - return &MockCommitStatusUpdater_UpdateProject_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} -} - -type MockCommitStatusUpdater_UpdateProject_OngoingVerification struct { - mock *MockCommitStatusUpdater - methodInvocations []pegomock.MethodInvocation -} - -func (c *MockCommitStatusUpdater_UpdateProject_OngoingVerification) GetCapturedArguments() (command.ProjectContext, command.Name, models.CommitStatus, string) { - _param0, _param1, _param2, _param3 := c.GetAllCapturedArguments() - return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1], _param3[len(_param3)-1] -} - -func (c *MockCommitStatusUpdater_UpdateProject_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []command.Name, _param2 []models.CommitStatus, _param3 []string) { - params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) - if len(params) > 0 { - _param0 = make([]command.ProjectContext, len(c.methodInvocations)) - for u, param := range params[0] { - _param0[u] = param.(command.ProjectContext) - } - _param1 = make([]command.Name, len(c.methodInvocations)) - for u, param := range params[1] { - _param1[u] = param.(command.Name) - } - _param2 = make([]models.CommitStatus, len(c.methodInvocations)) - for u, param := range params[2] { - _param2[u] = param.(models.CommitStatus) - } - _param3 = make([]string, len(c.methodInvocations)) - for u, param := range params[3] { - _param3[u] = param.(string) - } - } - return -} diff --git a/server/events/mocks/mock_job_url_setter.go b/server/events/mocks/mock_job_url_setter.go index 763e3d9a24..1405c720bc 100644 --- a/server/events/mocks/mock_job_url_setter.go +++ b/server/events/mocks/mock_job_url_setter.go @@ -26,11 +26,11 @@ func NewMockJobURLSetter(options ...pegomock.Option) *MockJobURLSetter { func (mock *MockJobURLSetter) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh } func (mock *MockJobURLSetter) FailHandler() pegomock.FailHandler { return mock.fail } -func (mock *MockJobURLSetter) SetJobURLWithStatus(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus) error { +func (mock *MockJobURLSetter) SetJobURLWithStatus(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus, _param3 *command.ProjectResult) error { if mock == nil { panic("mock must not be nil. Use myMock := NewMockJobURLSetter().") } - params := []pegomock.Param{_param0, _param1, _param2} + params := []pegomock.Param{_param0, _param1, _param2, _param3} result := pegomock.GetGenericMockFrom(mock).Invoke("SetJobURLWithStatus", params, []reflect.Type{reflect.TypeOf((*error)(nil)).Elem()}) var ret0 error if len(result) != 0 { @@ -78,8 +78,8 @@ type VerifierMockJobURLSetter struct { timeout time.Duration } -func (verifier *VerifierMockJobURLSetter) SetJobURLWithStatus(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus) *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification { - params := []pegomock.Param{_param0, _param1, _param2} +func (verifier *VerifierMockJobURLSetter) SetJobURLWithStatus(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus, _param3 *command.ProjectResult) *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification { + params := []pegomock.Param{_param0, _param1, _param2, _param3} methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "SetJobURLWithStatus", params, verifier.timeout) return &MockJobURLSetter_SetJobURLWithStatus_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } @@ -89,12 +89,12 @@ type MockJobURLSetter_SetJobURLWithStatus_OngoingVerification struct { methodInvocations []pegomock.MethodInvocation } -func (c *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification) GetCapturedArguments() (command.ProjectContext, command.Name, models.CommitStatus) { - _param0, _param1, _param2 := c.GetAllCapturedArguments() - return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1] +func (c *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification) GetCapturedArguments() (command.ProjectContext, command.Name, models.CommitStatus, *command.ProjectResult) { + _param0, _param1, _param2, _param3 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1], _param3[len(_param3)-1] } -func (c *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []command.Name, _param2 []models.CommitStatus) { +func (c *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []command.Name, _param2 []models.CommitStatus, _param3 []*command.ProjectResult) { params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) if len(params) > 0 { _param0 = make([]command.ProjectContext, len(c.methodInvocations)) @@ -109,6 +109,10 @@ func (c *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification) GetAllCapture for u, param := range params[2] { _param2[u] = param.(models.CommitStatus) } + _param3 = make([]*command.ProjectResult, len(c.methodInvocations)) + for u, param := range params[3] { + _param3[u] = param.(*command.ProjectResult) + } } return } diff --git a/server/events/project_command_runner.go b/server/events/project_command_runner.go index 1e8b6adfcc..036dfdfc8c 100644 --- a/server/events/project_command_runner.go +++ b/server/events/project_command_runner.go @@ -134,7 +134,7 @@ type ProjectCommandRunner interface { type JobURLSetter interface { // SetJobURLWithStatus sets the commit status for the project represented by // ctx and updates the status with and url to a job. - SetJobURLWithStatus(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus) error + SetJobURLWithStatus(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, result *command.ProjectResult) error } //go:generate pegomock generate -m --package mocks -o mocks/mock_job_message_sender.go JobMessageSender @@ -167,7 +167,7 @@ func (p *ProjectOutputWrapper) updateProjectPRStatus(commandName command.Name, c // Create a PR status to track project's plan status. The status will // include a link to view the progress of atlantis plan command in real // time - if err := p.JobURLSetter.SetJobURLWithStatus(ctx, commandName, models.PendingCommitStatus); err != nil { + if err := p.JobURLSetter.SetJobURLWithStatus(ctx, commandName, models.PendingCommitStatus, nil); err != nil { ctx.Log.Err("updating project PR status", err) } @@ -175,14 +175,14 @@ func (p *ProjectOutputWrapper) updateProjectPRStatus(commandName command.Name, c result := execute(ctx) if result.Error != nil || result.Failure != "" { - if err := p.JobURLSetter.SetJobURLWithStatus(ctx, commandName, models.FailedCommitStatus); err != nil { + if err := p.JobURLSetter.SetJobURLWithStatus(ctx, commandName, models.FailedCommitStatus, &result); err != nil { ctx.Log.Err("updating project PR status", err) } return result } - if err := p.JobURLSetter.SetJobURLWithStatus(ctx, commandName, models.SuccessCommitStatus); err != nil { + if err := p.JobURLSetter.SetJobURLWithStatus(ctx, commandName, models.SuccessCommitStatus, &result); err != nil { ctx.Log.Err("updating project PR status", err) } diff --git a/server/events/project_command_runner_test.go b/server/events/project_command_runner_test.go index ed701ce896..aa2d10071a 100644 --- a/server/events/project_command_runner_test.go +++ b/server/events/project_command_runner_test.go @@ -227,8 +227,8 @@ func TestProjectOutputWrapper(t *testing.T) { runner.Apply(ctx) } - mockJobURLSetter.VerifyWasCalled(Once()).SetJobURLWithStatus(ctx, c.CommandName, models.PendingCommitStatus) - mockJobURLSetter.VerifyWasCalled(Once()).SetJobURLWithStatus(ctx, c.CommandName, expCommitStatus) + mockJobURLSetter.VerifyWasCalled(Once()).SetJobURLWithStatus(ctx, c.CommandName, models.PendingCommitStatus, nil) + mockJobURLSetter.VerifyWasCalled(Once()).SetJobURLWithStatus(ctx, c.CommandName, expCommitStatus, &prjResult) switch c.CommandName { case command.Plan: diff --git a/server/jobs/job_url_setter.go b/server/jobs/job_url_setter.go index d7ac83f10f..85ca95d2ce 100644 --- a/server/jobs/job_url_setter.go +++ b/server/jobs/job_url_setter.go @@ -17,7 +17,7 @@ type ProjectJobURLGenerator interface { type ProjectStatusUpdater interface { // UpdateProject sets the commit status for the project represented by // ctx. - UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) error + UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string, result *command.ProjectResult) error } type JobURLSetter struct { @@ -32,11 +32,11 @@ func NewJobURLSetter(projectJobURLGenerator ProjectJobURLGenerator, projectStatu } } -func (j *JobURLSetter) SetJobURLWithStatus(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus) error { +func (j *JobURLSetter) SetJobURLWithStatus(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, result *command.ProjectResult) error { url, err := j.projectJobURLGenerator.GenerateProjectJobURL(ctx) if err != nil { return err } - return j.projectStatusUpdater.UpdateProject(ctx, cmdName, status, url) + return j.projectStatusUpdater.UpdateProject(ctx, cmdName, status, url, result) } diff --git a/server/jobs/job_url_setter_test.go b/server/jobs/job_url_setter_test.go index abea9da096..45cbf6948f 100644 --- a/server/jobs/job_url_setter_test.go +++ b/server/jobs/job_url_setter_test.go @@ -23,13 +23,14 @@ func TestJobURLSetter(t *testing.T) { projectJobURLGenerator := mocks.NewMockProjectJobURLGenerator() url := "url-to-project-jobs" jobURLSetter := jobs.NewJobURLSetter(projectJobURLGenerator, projectStatusUpdater) + result := &command.ProjectResult{} When(projectJobURLGenerator.GenerateProjectJobURL(matchers.EqCommandProjectContext(ctx))).ThenReturn(url, nil) - When(projectStatusUpdater.UpdateProject(ctx, command.Plan, models.PendingCommitStatus, url)).ThenReturn(nil) - err := jobURLSetter.SetJobURLWithStatus(ctx, command.Plan, models.PendingCommitStatus) + When(projectStatusUpdater.UpdateProject(ctx, command.Plan, models.PendingCommitStatus, url, nil)).ThenReturn(nil) + err := jobURLSetter.SetJobURLWithStatus(ctx, command.Plan, models.PendingCommitStatus, result) Ok(t, err) - projectStatusUpdater.VerifyWasCalledOnce().UpdateProject(ctx, command.Plan, models.PendingCommitStatus, "url-to-project-jobs") + projectStatusUpdater.VerifyWasCalledOnce().UpdateProject(ctx, command.Plan, models.PendingCommitStatus, "url-to-project-jobs", result) }) t.Run("update project status with project jobs url error", func(t *testing.T) { @@ -39,7 +40,7 @@ func TestJobURLSetter(t *testing.T) { jobURLSetter := jobs.NewJobURLSetter(projectJobURLGenerator, projectStatusUpdater) When(projectJobURLGenerator.GenerateProjectJobURL(matchers.EqCommandProjectContext(ctx))).ThenReturn("url-to-project-jobs", errors.New("some error")) - err := jobURLSetter.SetJobURLWithStatus(ctx, command.Plan, models.PendingCommitStatus) + err := jobURLSetter.SetJobURLWithStatus(ctx, command.Plan, models.PendingCommitStatus, nil) assert.Error(t, err) }) } diff --git a/server/jobs/mocks/matchers/ptr_to_command_projectresult.go b/server/jobs/mocks/matchers/ptr_to_command_projectresult.go new file mode 100644 index 0000000000..a3f5a7d10e --- /dev/null +++ b/server/jobs/mocks/matchers/ptr_to_command_projectresult.go @@ -0,0 +1,33 @@ +// Code generated by pegomock. DO NOT EDIT. +package matchers + +import ( + "github.com/petergtz/pegomock" + "reflect" + + command "github.com/runatlantis/atlantis/server/events/command" +) + +func AnyPtrToCommandProjectResult() *command.ProjectResult { + pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(*command.ProjectResult))(nil)).Elem())) + var nullValue *command.ProjectResult + return nullValue +} + +func EqPtrToCommandProjectResult(value *command.ProjectResult) *command.ProjectResult { + pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value}) + var nullValue *command.ProjectResult + return nullValue +} + +func NotEqPtrToCommandProjectResult(value *command.ProjectResult) *command.ProjectResult { + pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value}) + var nullValue *command.ProjectResult + return nullValue +} + +func PtrToCommandProjectResultThat(matcher pegomock.ArgumentMatcher) *command.ProjectResult { + pegomock.RegisterMatcher(matcher) + var nullValue *command.ProjectResult + return nullValue +} diff --git a/server/jobs/mocks/mock_project_status_updater.go b/server/jobs/mocks/mock_project_status_updater.go index a7282ef1e3..cf1cfff767 100644 --- a/server/jobs/mocks/mock_project_status_updater.go +++ b/server/jobs/mocks/mock_project_status_updater.go @@ -26,11 +26,11 @@ func NewMockProjectStatusUpdater(options ...pegomock.Option) *MockProjectStatusU func (mock *MockProjectStatusUpdater) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh } func (mock *MockProjectStatusUpdater) FailHandler() pegomock.FailHandler { return mock.fail } -func (mock *MockProjectStatusUpdater) UpdateProject(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus, _param3 string) error { +func (mock *MockProjectStatusUpdater) UpdateProject(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus, _param3 string, _param4 *command.ProjectResult) error { if mock == nil { panic("mock must not be nil. Use myMock := NewMockProjectStatusUpdater().") } - params := []pegomock.Param{_param0, _param1, _param2, _param3} + params := []pegomock.Param{_param0, _param1, _param2, _param3, _param4} result := pegomock.GetGenericMockFrom(mock).Invoke("UpdateProject", params, []reflect.Type{reflect.TypeOf((*error)(nil)).Elem()}) var ret0 error if len(result) != 0 { @@ -78,8 +78,8 @@ type VerifierMockProjectStatusUpdater struct { timeout time.Duration } -func (verifier *VerifierMockProjectStatusUpdater) UpdateProject(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus, _param3 string) *MockProjectStatusUpdater_UpdateProject_OngoingVerification { - params := []pegomock.Param{_param0, _param1, _param2, _param3} +func (verifier *VerifierMockProjectStatusUpdater) UpdateProject(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus, _param3 string, _param4 *command.ProjectResult) *MockProjectStatusUpdater_UpdateProject_OngoingVerification { + params := []pegomock.Param{_param0, _param1, _param2, _param3, _param4} methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "UpdateProject", params, verifier.timeout) return &MockProjectStatusUpdater_UpdateProject_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } @@ -89,12 +89,12 @@ type MockProjectStatusUpdater_UpdateProject_OngoingVerification struct { methodInvocations []pegomock.MethodInvocation } -func (c *MockProjectStatusUpdater_UpdateProject_OngoingVerification) GetCapturedArguments() (command.ProjectContext, command.Name, models.CommitStatus, string) { - _param0, _param1, _param2, _param3 := c.GetAllCapturedArguments() - return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1], _param3[len(_param3)-1] +func (c *MockProjectStatusUpdater_UpdateProject_OngoingVerification) GetCapturedArguments() (command.ProjectContext, command.Name, models.CommitStatus, string, *command.ProjectResult) { + _param0, _param1, _param2, _param3, _param4 := c.GetAllCapturedArguments() + return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1], _param3[len(_param3)-1], _param4[len(_param4)-1] } -func (c *MockProjectStatusUpdater_UpdateProject_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []command.Name, _param2 []models.CommitStatus, _param3 []string) { +func (c *MockProjectStatusUpdater_UpdateProject_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []command.Name, _param2 []models.CommitStatus, _param3 []string, _param4 []*command.ProjectResult) { params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) if len(params) > 0 { _param0 = make([]command.ProjectContext, len(c.methodInvocations)) @@ -113,6 +113,10 @@ func (c *MockProjectStatusUpdater_UpdateProject_OngoingVerification) GetAllCaptu for u, param := range params[3] { _param3[u] = param.(string) } + _param4 = make([]*command.ProjectResult, len(c.methodInvocations)) + for u, param := range params[4] { + _param4[u] = param.(*command.ProjectResult) + } } return }