From 9eda6a3f1be8aa5e9835571837c91d99205468aa Mon Sep 17 00:00:00 2001 From: Luke Massa Date: Sun, 16 Nov 2025 00:57:29 -0500 Subject: [PATCH] chore: Remove invalid policy owner tests from command_runner_test Signed-off-by: Luke Massa --- server/events/command_runner_test.go | 108 --------------------------- 1 file changed, 108 deletions(-) diff --git a/server/events/command_runner_test.go b/server/events/command_runner_test.go index 84da1ffcc6..77b4d7841f 100644 --- a/server/events/command_runner_test.go +++ b/server/events/command_runner_test.go @@ -1068,114 +1068,6 @@ func TestRunGenericPlanCommand_DiscardApprovals(t *testing.T) { vcsClient.VerifyWasCalledOnce().DiscardReviews(Any[logging.SimpleLogging](), Any[models.Repo](), Any[models.PullRequest]()) } -func TestFailedApprovalCreatesFailedStatusUpdate(t *testing.T) { - t.Log("if \"atlantis approve_policies\" is run by non policy owner policy check status fails.") - setup(t) - tmp := t.TempDir() - boltDB, err := boltdb.New(tmp) - t.Cleanup(func() { - boltDB.Close() - }) - Ok(t, err) - dbUpdater.Database = boltDB - applyCommandRunner.Database = boltDB - autoMerger.GlobalAutomerge = true - defer func() { autoMerger.GlobalAutomerge = false }() - - pull := &github.PullRequest{ - State: github.Ptr("open"), - } - - modelPull := models.PullRequest{ - BaseRepo: testdata.GithubRepo, - State: models.OpenPullState, - Num: testdata.Pull.Num, - } - When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), Eq(testdata.Pull.Num))).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(Any[logging.SimpleLogging](), Eq(pull))).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - - When(projectCommandBuilder.BuildApprovePoliciesCommands(Any[*command.Context](), Any[*events.CommentCommand]())).ThenReturn([]command.ProjectContext{ - { - CommandName: command.ApprovePolicies, - }, - { - CommandName: command.ApprovePolicies, - }, - }, nil) - - When(workingDir.GetPullDir(testdata.GithubRepo, testdata.Pull)).ThenReturn(tmp, nil) - - ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, &testdata.Pull, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies}) - commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount( - Any[logging.SimpleLogging](), - Any[models.Repo](), - Any[models.PullRequest](), - Eq[models.CommitStatus](models.SuccessCommitStatus), - Eq[command.Name](command.PolicyCheck), - Eq(0), - Eq(2), - ) -} - -func TestApprovedPoliciesUpdateFailedPolicyStatus(t *testing.T) { - t.Log("if \"atlantis approve_policies\" is run by policy owner all policy checks are approved.") - setup(t) - tmp := t.TempDir() - boltDB, err := boltdb.New(tmp) - t.Cleanup(func() { - boltDB.Close() - }) - Ok(t, err) - dbUpdater.Database = boltDB - applyCommandRunner.Database = boltDB - autoMerger.GlobalAutomerge = true - defer func() { autoMerger.GlobalAutomerge = false }() - - pull := &github.PullRequest{ - State: github.Ptr("open"), - } - - modelPull := models.PullRequest{ - BaseRepo: testdata.GithubRepo, - State: models.OpenPullState, - Num: testdata.Pull.Num, - } - When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), Eq(testdata.Pull.Num))).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(Any[logging.SimpleLogging](), Eq(pull))).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - - When(projectCommandBuilder.BuildApprovePoliciesCommands(Any[*command.Context](), Any[*events.CommentCommand]())).ThenReturn([]command.ProjectContext{ - { - CommandName: command.ApprovePolicies, - PolicySets: valid.PolicySets{ - Owners: valid.PolicyOwners{ - Users: []string{testdata.User.Username}, - }, - }, - }, - }, nil) - - When(workingDir.GetPullDir(testdata.GithubRepo, testdata.Pull)).ThenReturn(tmp, nil) - When(projectCommandRunner.ApprovePolicies(Any[command.ProjectContext]())).Then(func(_ []Param) ReturnValues { - return ReturnValues{ - command.ProjectResult{ - Command: command.PolicyCheck, - PolicyCheckResults: &models.PolicyCheckResults{}, - }, - } - }) - - ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, &testdata.Pull, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies}) - commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount( - Any[logging.SimpleLogging](), - Any[models.Repo](), - Any[models.PullRequest](), - Eq[models.CommitStatus](models.SuccessCommitStatus), - Eq[command.Name](command.PolicyCheck), - Eq(1), - Eq(1), - ) -} - func TestApplyMergeablityWhenPolicyCheckFails(t *testing.T) { t.Log("if \"atlantis apply\" is run with failing policy check then apply is not performed") setup(t)