Skip to content

Commit a7aba99

Browse files
AndreZivianiijames-gc
authored andcommitted
fix: Tests broken by runatlantis#3503 (runatlantis#3583)
1 parent 0111a88 commit a7aba99

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

server/controllers/events/events_controller_e2e_test.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -901,10 +901,12 @@ func TestGitHubWorkflowWithPolicyCheck(t *testing.T) {
901901
},
902902
},
903903
{
904-
Description: "failing policy without policies passing and custom run steps",
905-
RepoDir: "policy-checks-custom-run-steps",
906-
ModifiedFiles: []string{"main.tf"},
907-
ExpAutoplan: true,
904+
Description: "failing policy without policies passing and custom run steps",
905+
RepoDir: "policy-checks-custom-run-steps",
906+
ModifiedFiles: []string{"main.tf"},
907+
PolicyCheck: true,
908+
ExpAutoplan: true,
909+
ExpPolicyChecks: true,
908910
Comments: []string{
909911
"atlantis apply",
910912
},
@@ -1160,10 +1162,10 @@ func TestGitHubWorkflowWithPolicyCheck(t *testing.T) {
11601162
expNumReplies--
11611163
}
11621164

1163-
_, _, actReplies, _ := vcsClient.VerifyWasCalled(Times(expNumReplies)).CreateComment(Any[models.Repo](), Any[int](), Any[string](), Any[string]()).GetAllCapturedArguments()
11641165
if !c.ExpPolicyChecks {
11651166
expNumReplies--
11661167
}
1168+
_, _, actReplies, _ := vcsClient.VerifyWasCalled(Times(expNumReplies)).CreateComment(Any[models.Repo](), Any[int](), Any[string](), Any[string]()).GetAllCapturedArguments()
11671169

11681170
Assert(t, len(c.ExpReplies) == len(actReplies), "missing expected replies, got %d but expected %d", len(actReplies), len(c.ExpReplies))
11691171
for i, expReply := range c.ExpReplies {

server/events/project_command_builder_internal_test.go

+11-10
Original file line numberDiff line numberDiff line change
@@ -989,9 +989,9 @@ repos:
989989
},
990990
Pull: pull,
991991
ProjectName: "",
992-
PlanRequirements: []string{},
993-
ApplyRequirements: []string{},
994-
ImportRequirements: []string{},
992+
PlanRequirements: []string{"policies_passed"},
993+
ApplyRequirements: []string{"policies_passed"},
994+
ImportRequirements: []string{"policies_passed"},
995995
RePlanCmd: "atlantis plan -d project1 -w myworkspace -- flag",
996996
RepoRelDir: "project1",
997997
User: models.User{},
@@ -1051,13 +1051,13 @@ workflows:
10511051
},
10521052
Pull: pull,
10531053
ProjectName: "",
1054-
PlanRequirements: []string{},
1054+
PlanRequirements: []string{"policies_passed"},
10551055
ApplyRequirements: []string{},
1056-
ImportRequirements: []string{},
1056+
ImportRequirements: []string{"policies_passed"},
10571057
RepoConfigVersion: 3,
10581058
RePlanCmd: "atlantis plan -d project1 -w myworkspace -- flag",
10591059
RepoRelDir: "project1",
1060-
TerraformVersion: mustVersion("10.0"),
1060+
TerraformVersion: mustVersion("v10.0"),
10611061
User: models.User{},
10621062
Verbose: true,
10631063
Workspace: "myworkspace",
@@ -1092,10 +1092,11 @@ workflows:
10921092
Ok(t, os.WriteFile(globalCfgPath, []byte(c.globalCfg), 0600))
10931093
parser := &config.ParserValidator{}
10941094
globalCfgArgs := valid.GlobalCfgArgs{
1095-
AllowRepoCfg: false,
1096-
MergeableReq: false,
1097-
ApprovedReq: false,
1098-
UnDivergedReq: false,
1095+
AllowRepoCfg: false,
1096+
MergeableReq: false,
1097+
ApprovedReq: false,
1098+
UnDivergedReq: false,
1099+
PolicyCheckEnabled: true,
10991100
}
11001101

11011102
globalCfg, err := parser.ParseGlobalCfg(globalCfgPath, valid.NewGlobalCfgFromArgs(globalCfgArgs))

server/events/project_command_builder_test.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -1398,10 +1398,11 @@ func TestDefaultProjectCommandBuilder_WithPolicyCheckEnabled_BuildAutoplanComman
13981398
When(vcsClient.GetModifiedFiles(Any[models.Repo](), Any[models.PullRequest]())).ThenReturn([]string{"main.tf"}, nil)
13991399

14001400
globalCfgArgs := valid.GlobalCfgArgs{
1401-
AllowRepoCfg: false,
1402-
MergeableReq: false,
1403-
ApprovedReq: false,
1404-
UnDivergedReq: false,
1401+
AllowRepoCfg: false,
1402+
MergeableReq: false,
1403+
ApprovedReq: false,
1404+
UnDivergedReq: false,
1405+
PolicyCheckEnabled: true,
14051406
}
14061407

14071408
globalCfg := valid.NewGlobalCfgFromArgs(globalCfgArgs)

0 commit comments

Comments
 (0)