Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/controllers/api_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (a *APIController) apiPlan(request *APIRequest, ctx *command.Context) (*com
}
}

res := a.ProjectPlanCommandRunner.Plan(cmd)
res := events.RunOneProjectCmd(a.ProjectPlanCommandRunner.Plan, cmd)
projectResults = append(projectResults, res)

a.PostWorkflowHooksCommandRunner.RunPostHooks(ctx, cc[i]) // nolint: errcheck
Expand Down Expand Up @@ -323,7 +323,7 @@ func (a *APIController) apiApply(request *APIRequest, ctx *command.Context) (*co
}
}

res := a.ProjectApplyCommandRunner.Apply(cmd)
res := events.RunOneProjectCmd(a.ProjectApplyCommandRunner.Apply, cmd)
projectResults = append(projectResults, res)

a.PostWorkflowHooksCommandRunner.RunPostHooks(ctx, cc[i]) // nolint: errcheck
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/api_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ func setup(t *testing.T) (controllers.APIController, *MockProjectCommandBuilder,
}}, nil)

projectCommandRunner := NewMockProjectCommandRunner()
When(projectCommandRunner.Plan(Any[command.ProjectContext]())).ThenReturn(command.ProjectResult{
When(projectCommandRunner.Plan(Any[command.ProjectContext]())).ThenReturn(command.ProjectCommandOutput{
PlanSuccess: &models.PlanSuccess{},
})
When(projectCommandRunner.Apply(Any[command.ProjectContext]())).ThenReturn(command.ProjectResult{
When(projectCommandRunner.Apply(Any[command.ProjectContext]())).ThenReturn(command.ProjectCommandOutput{
ApplySuccess: "success",
})

Expand Down
8 changes: 5 additions & 3 deletions server/controllers/locks_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,11 @@ func TestDeleteLock_UpdateProjectStatus(t *testing.T) {
Command: command.Plan,
RepoRelDir: projectPath,
Workspace: workspaceName,
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "tf-output",
LockURL: "lock-url",
ProjectCommandOutput: command.ProjectCommandOutput{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "tf-output",
LockURL: "lock-url",
},
},
},
})
Expand Down
118 changes: 74 additions & 44 deletions server/core/boltdb/boltdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,9 @@ func TestPullStatus_UpdateGet(t *testing.T) {
Command: command.Plan,
RepoRelDir: ".",
Workspace: "default",
Failure: "failure",
ProjectCommandOutput: command.ProjectCommandOutput{
Failure: "failure",
},
},
})
Ok(t, err)
Expand Down Expand Up @@ -524,7 +526,9 @@ func TestPullStatus_UpdateDeleteGet(t *testing.T) {
{
RepoRelDir: ".",
Workspace: "default",
Failure: "failure",
ProjectCommandOutput: command.ProjectCommandOutput{
Failure: "failure",
},
},
})
Ok(t, err)
Expand Down Expand Up @@ -570,12 +574,16 @@ func TestPullStatus_UpdateProject(t *testing.T) {
{
RepoRelDir: ".",
Workspace: "default",
Failure: "failure",
ProjectCommandOutput: command.ProjectCommandOutput{
Failure: "failure",
},
},
{
RepoRelDir: ".",
Workspace: "staging",
ApplySuccess: "success!",
RepoRelDir: ".",
Workspace: "staging",
ProjectCommandOutput: command.ProjectCommandOutput{
ApplySuccess: "success!",
},
},
})
Ok(t, err)
Expand Down Expand Up @@ -634,7 +642,9 @@ func TestPullStatus_UpdateNewCommit(t *testing.T) {
{
RepoRelDir: ".",
Workspace: "default",
Failure: "failure",
ProjectCommandOutput: command.ProjectCommandOutput{
Failure: "failure",
},
},
})
Ok(t, err)
Expand All @@ -643,9 +653,11 @@ func TestPullStatus_UpdateNewCommit(t *testing.T) {
status, err := b.UpdatePullWithResults(pull,
[]command.ProjectResult{
{
RepoRelDir: ".",
Workspace: "staging",
ApplySuccess: "success!",
RepoRelDir: ".",
Workspace: "staging",
ProjectCommandOutput: command.ProjectCommandOutput{
ApplySuccess: "success!",
},
},
})

Expand Down Expand Up @@ -698,24 +710,30 @@ func TestPullStatus_UpdateMerge_Apply(t *testing.T) {
Command: command.Plan,
RepoRelDir: "mergeme",
Workspace: "default",
Failure: "failure",
ProjectCommandOutput: command.ProjectCommandOutput{
Failure: "failure",
},
},
{
Command: command.Plan,
RepoRelDir: "projectname",
Workspace: "default",
ProjectName: "projectname",
Failure: "failure",
ProjectCommandOutput: command.ProjectCommandOutput{
Failure: "failure",
},
},
{
Command: command.Plan,
RepoRelDir: "staythesame",
Workspace: "default",
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "tf out",
LockURL: "lock-url",
RePlanCmd: "plan command",
ApplyCmd: "apply command",
ProjectCommandOutput: command.ProjectCommandOutput{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "tf out",
LockURL: "lock-url",
RePlanCmd: "plan command",
ApplyCmd: "apply command",
},
},
},
})
Expand All @@ -724,23 +742,29 @@ func TestPullStatus_UpdateMerge_Apply(t *testing.T) {
updateStatus, err := b.UpdatePullWithResults(pull,
[]command.ProjectResult{
{
Command: command.Apply,
RepoRelDir: "mergeme",
Workspace: "default",
ApplySuccess: "applied!",
Command: command.Apply,
RepoRelDir: "mergeme",
Workspace: "default",
ProjectCommandOutput: command.ProjectCommandOutput{
ApplySuccess: "applied!",
},
},
{
Command: command.Apply,
RepoRelDir: "projectname",
Workspace: "default",
ProjectName: "projectname",
Error: errors.New("apply error"),
ProjectCommandOutput: command.ProjectCommandOutput{
Error: errors.New("apply error"),
},
},
{
Command: command.Apply,
RepoRelDir: "newresult",
Workspace: "default",
ApplySuccess: "success!",
Command: command.Apply,
RepoRelDir: "newresult",
Workspace: "default",
ProjectCommandOutput: command.ProjectCommandOutput{
ApplySuccess: "success!",
},
},
})
Ok(t, err)
Expand Down Expand Up @@ -811,12 +835,14 @@ func TestPullStatus_UpdateMerge_ApprovePolicies(t *testing.T) {
Command: command.PolicyCheck,
RepoRelDir: "mergeme",
Workspace: "default",
Failure: "policy failure",
PolicyCheckResults: &models.PolicyCheckResults{
PolicySetResults: []models.PolicySetResult{
{
PolicySetName: "policy1",
ReqApprovals: 1,
ProjectCommandOutput: command.ProjectCommandOutput{
Failure: "policy failure",
PolicyCheckResults: &models.PolicyCheckResults{
PolicySetResults: []models.PolicySetResult{
{
PolicySetName: "policy1",
ReqApprovals: 1,
},
},
},
},
Expand All @@ -826,12 +852,14 @@ func TestPullStatus_UpdateMerge_ApprovePolicies(t *testing.T) {
RepoRelDir: "projectname",
Workspace: "default",
ProjectName: "projectname",
Failure: "policy failure",
PolicyCheckResults: &models.PolicyCheckResults{
PolicySetResults: []models.PolicySetResult{
{
PolicySetName: "policy1",
ReqApprovals: 1,
ProjectCommandOutput: command.ProjectCommandOutput{
Failure: "policy failure",
PolicyCheckResults: &models.PolicyCheckResults{
PolicySetResults: []models.PolicySetResult{
{
PolicySetName: "policy1",
ReqApprovals: 1,
},
},
},
},
Expand All @@ -845,12 +873,14 @@ func TestPullStatus_UpdateMerge_ApprovePolicies(t *testing.T) {
Command: command.ApprovePolicies,
RepoRelDir: "mergeme",
Workspace: "default",
PolicyCheckResults: &models.PolicyCheckResults{
PolicySetResults: []models.PolicySetResult{
{
PolicySetName: "policy1",
ReqApprovals: 1,
CurApprovals: 1,
ProjectCommandOutput: command.ProjectCommandOutput{
PolicyCheckResults: &models.PolicyCheckResults{
PolicySetResults: []models.PolicySetResult{
{
PolicySetName: "policy1",
ReqApprovals: 1,
CurApprovals: 1,
},
},
},
},
Expand Down
Loading
Loading