Skip to content

Commit a7567dc

Browse files
authored
chore: Remove invalid policy owner tests from command_runner_test (#5963)
Signed-off-by: Luke Massa <[email protected]>
1 parent 46ba801 commit a7567dc

File tree

1 file changed

+0
-108
lines changed

1 file changed

+0
-108
lines changed

server/events/command_runner_test.go

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,114 +1068,6 @@ func TestRunGenericPlanCommand_DiscardApprovals(t *testing.T) {
10681068
vcsClient.VerifyWasCalledOnce().DiscardReviews(Any[logging.SimpleLogging](), Any[models.Repo](), Any[models.PullRequest]())
10691069
}
10701070

1071-
func TestFailedApprovalCreatesFailedStatusUpdate(t *testing.T) {
1072-
t.Log("if \"atlantis approve_policies\" is run by non policy owner policy check status fails.")
1073-
setup(t)
1074-
tmp := t.TempDir()
1075-
boltDB, err := boltdb.New(tmp)
1076-
t.Cleanup(func() {
1077-
boltDB.Close()
1078-
})
1079-
Ok(t, err)
1080-
dbUpdater.Database = boltDB
1081-
applyCommandRunner.Database = boltDB
1082-
autoMerger.GlobalAutomerge = true
1083-
defer func() { autoMerger.GlobalAutomerge = false }()
1084-
1085-
pull := &github.PullRequest{
1086-
State: github.Ptr("open"),
1087-
}
1088-
1089-
modelPull := models.PullRequest{
1090-
BaseRepo: testdata.GithubRepo,
1091-
State: models.OpenPullState,
1092-
Num: testdata.Pull.Num,
1093-
}
1094-
When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), Eq(testdata.Pull.Num))).ThenReturn(pull, nil)
1095-
When(eventParsing.ParseGithubPull(Any[logging.SimpleLogging](), Eq(pull))).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil)
1096-
1097-
When(projectCommandBuilder.BuildApprovePoliciesCommands(Any[*command.Context](), Any[*events.CommentCommand]())).ThenReturn([]command.ProjectContext{
1098-
{
1099-
CommandName: command.ApprovePolicies,
1100-
},
1101-
{
1102-
CommandName: command.ApprovePolicies,
1103-
},
1104-
}, nil)
1105-
1106-
When(workingDir.GetPullDir(testdata.GithubRepo, testdata.Pull)).ThenReturn(tmp, nil)
1107-
1108-
ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, &testdata.Pull, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies})
1109-
commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount(
1110-
Any[logging.SimpleLogging](),
1111-
Any[models.Repo](),
1112-
Any[models.PullRequest](),
1113-
Eq[models.CommitStatus](models.SuccessCommitStatus),
1114-
Eq[command.Name](command.PolicyCheck),
1115-
Eq(0),
1116-
Eq(2),
1117-
)
1118-
}
1119-
1120-
func TestApprovedPoliciesUpdateFailedPolicyStatus(t *testing.T) {
1121-
t.Log("if \"atlantis approve_policies\" is run by policy owner all policy checks are approved.")
1122-
setup(t)
1123-
tmp := t.TempDir()
1124-
boltDB, err := boltdb.New(tmp)
1125-
t.Cleanup(func() {
1126-
boltDB.Close()
1127-
})
1128-
Ok(t, err)
1129-
dbUpdater.Database = boltDB
1130-
applyCommandRunner.Database = boltDB
1131-
autoMerger.GlobalAutomerge = true
1132-
defer func() { autoMerger.GlobalAutomerge = false }()
1133-
1134-
pull := &github.PullRequest{
1135-
State: github.Ptr("open"),
1136-
}
1137-
1138-
modelPull := models.PullRequest{
1139-
BaseRepo: testdata.GithubRepo,
1140-
State: models.OpenPullState,
1141-
Num: testdata.Pull.Num,
1142-
}
1143-
When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), Eq(testdata.Pull.Num))).ThenReturn(pull, nil)
1144-
When(eventParsing.ParseGithubPull(Any[logging.SimpleLogging](), Eq(pull))).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil)
1145-
1146-
When(projectCommandBuilder.BuildApprovePoliciesCommands(Any[*command.Context](), Any[*events.CommentCommand]())).ThenReturn([]command.ProjectContext{
1147-
{
1148-
CommandName: command.ApprovePolicies,
1149-
PolicySets: valid.PolicySets{
1150-
Owners: valid.PolicyOwners{
1151-
Users: []string{testdata.User.Username},
1152-
},
1153-
},
1154-
},
1155-
}, nil)
1156-
1157-
When(workingDir.GetPullDir(testdata.GithubRepo, testdata.Pull)).ThenReturn(tmp, nil)
1158-
When(projectCommandRunner.ApprovePolicies(Any[command.ProjectContext]())).Then(func(_ []Param) ReturnValues {
1159-
return ReturnValues{
1160-
command.ProjectResult{
1161-
Command: command.PolicyCheck,
1162-
PolicyCheckResults: &models.PolicyCheckResults{},
1163-
},
1164-
}
1165-
})
1166-
1167-
ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, &testdata.Pull, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies})
1168-
commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount(
1169-
Any[logging.SimpleLogging](),
1170-
Any[models.Repo](),
1171-
Any[models.PullRequest](),
1172-
Eq[models.CommitStatus](models.SuccessCommitStatus),
1173-
Eq[command.Name](command.PolicyCheck),
1174-
Eq(1),
1175-
Eq(1),
1176-
)
1177-
}
1178-
11791071
func TestApplyMergeablityWhenPolicyCheckFails(t *testing.T) {
11801072
t.Log("if \"atlantis apply\" is run with failing policy check then apply is not performed")
11811073
setup(t)

0 commit comments

Comments
 (0)