From b6466bdfd2dcf24e51ddb622f2178b5fdbeb885b Mon Sep 17 00:00:00 2001 From: Andre Ziviani <7469258+AndreZiviani@users.noreply.github.com> Date: Thu, 6 Jul 2023 19:22:47 -0300 Subject: [PATCH] fix: Tests broken by #3503 (#3583) --- .../events/events_controller_e2e_test.go | 12 ++++++----- .../project_command_builder_internal_test.go | 21 ++++++++++--------- server/events/project_command_builder_test.go | 9 ++++---- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go index b5485e22c9..d489c1079c 100644 --- a/server/controllers/events/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -901,10 +901,12 @@ func TestGitHubWorkflowWithPolicyCheck(t *testing.T) { }, }, { - Description: "failing policy without policies passing and custom run steps", - RepoDir: "policy-checks-custom-run-steps", - ModifiedFiles: []string{"main.tf"}, - ExpAutoplan: true, + Description: "failing policy without policies passing and custom run steps", + RepoDir: "policy-checks-custom-run-steps", + ModifiedFiles: []string{"main.tf"}, + PolicyCheck: true, + ExpAutoplan: true, + ExpPolicyChecks: true, Comments: []string{ "atlantis apply", }, @@ -1160,10 +1162,10 @@ func TestGitHubWorkflowWithPolicyCheck(t *testing.T) { expNumReplies-- } - _, _, actReplies, _ := vcsClient.VerifyWasCalled(Times(expNumReplies)).CreateComment(Any[models.Repo](), Any[int](), Any[string](), Any[string]()).GetAllCapturedArguments() if !c.ExpPolicyChecks { expNumReplies-- } + _, _, actReplies, _ := vcsClient.VerifyWasCalled(Times(expNumReplies)).CreateComment(Any[models.Repo](), Any[int](), Any[string](), Any[string]()).GetAllCapturedArguments() Assert(t, len(c.ExpReplies) == len(actReplies), "missing expected replies, got %d but expected %d", len(actReplies), len(c.ExpReplies)) for i, expReply := range c.ExpReplies { diff --git a/server/events/project_command_builder_internal_test.go b/server/events/project_command_builder_internal_test.go index 8fbe51177c..069218ae6c 100644 --- a/server/events/project_command_builder_internal_test.go +++ b/server/events/project_command_builder_internal_test.go @@ -989,9 +989,9 @@ repos: }, Pull: pull, ProjectName: "", - PlanRequirements: []string{}, - ApplyRequirements: []string{}, - ImportRequirements: []string{}, + PlanRequirements: []string{"policies_passed"}, + ApplyRequirements: []string{"policies_passed"}, + ImportRequirements: []string{"policies_passed"}, RePlanCmd: "atlantis plan -d project1 -w myworkspace -- flag", RepoRelDir: "project1", User: models.User{}, @@ -1051,13 +1051,13 @@ workflows: }, Pull: pull, ProjectName: "", - PlanRequirements: []string{}, + PlanRequirements: []string{"policies_passed"}, ApplyRequirements: []string{}, - ImportRequirements: []string{}, + ImportRequirements: []string{"policies_passed"}, RepoConfigVersion: 3, RePlanCmd: "atlantis plan -d project1 -w myworkspace -- flag", RepoRelDir: "project1", - TerraformVersion: mustVersion("10.0"), + TerraformVersion: mustVersion("v10.0"), User: models.User{}, Verbose: true, Workspace: "myworkspace", @@ -1092,10 +1092,11 @@ workflows: Ok(t, os.WriteFile(globalCfgPath, []byte(c.globalCfg), 0600)) parser := &config.ParserValidator{} globalCfgArgs := valid.GlobalCfgArgs{ - AllowRepoCfg: false, - MergeableReq: false, - ApprovedReq: false, - UnDivergedReq: false, + AllowRepoCfg: false, + MergeableReq: false, + ApprovedReq: false, + UnDivergedReq: false, + PolicyCheckEnabled: true, } globalCfg, err := parser.ParseGlobalCfg(globalCfgPath, valid.NewGlobalCfgFromArgs(globalCfgArgs)) diff --git a/server/events/project_command_builder_test.go b/server/events/project_command_builder_test.go index 3969c711c3..59bdd09af0 100644 --- a/server/events/project_command_builder_test.go +++ b/server/events/project_command_builder_test.go @@ -1398,10 +1398,11 @@ func TestDefaultProjectCommandBuilder_WithPolicyCheckEnabled_BuildAutoplanComman When(vcsClient.GetModifiedFiles(Any[models.Repo](), Any[models.PullRequest]())).ThenReturn([]string{"main.tf"}, nil) globalCfgArgs := valid.GlobalCfgArgs{ - AllowRepoCfg: false, - MergeableReq: false, - ApprovedReq: false, - UnDivergedReq: false, + AllowRepoCfg: false, + MergeableReq: false, + ApprovedReq: false, + UnDivergedReq: false, + PolicyCheckEnabled: true, } globalCfg := valid.NewGlobalCfgFromArgs(globalCfgArgs)