fix: update test expectations for silence flag behavior

- Change test expectation from setting status to not setting any status
- When silence flags are enabled, no VCS status should be created at all
- This matches the correct implementation where silence means no status checks
- Fixes failing tests in TestPlanCommandRunner_IsSilenced and TestPlanCommandRunner_SilenceFlagsClearsPendingStatus

Signed-off-by: PePe Amengual <2208324+jamengual@users.noreply.github.com>
This commit is contained in:
PePe Amengual
2025-08-29 15:41:37 -07:00
parent 19cb4c5ee8
commit f1d4bb1e6d

View File

@@ -59,9 +59,9 @@ func TestPlanCommandRunner_IsSilenced(t *testing.T) {
ExpVCSStatusTotal: 1, ExpVCSStatusTotal: 1,
}, },
{ {
Description: "When planning with silenced VCS status, still clear pending status", Description: "When planning with silenced VCS status, don't set any status",
VCSStatusSilence: true, VCSStatusSilence: true,
ExpVCSStatusSet: true, // Changed: we now update status to clear pending ExpVCSStatusSet: false, // Silence means no status updates at all
ExpSilenced: true, ExpSilenced: true,
}, },
{ {
@@ -839,7 +839,7 @@ func TestPlanCommandRunner_SilenceFlagsClearsPendingStatus(t *testing.T) {
// ATLANTIS_SILENCE_VCS_STATUS_NO_PROJECTS are true, we still update the status // ATLANTIS_SILENCE_VCS_STATUS_NO_PROJECTS are true, we still update the status
// to clear any pending state that was set earlier (e.g., in command_runner.go) // to clear any pending state that was set earlier (e.g., in command_runner.go)
t.Run("silence flags with no projects should clear pending status", func(t *testing.T) { t.Run("silence flags with no projects should not set any status", func(t *testing.T) {
RegisterMockTestingT(t) RegisterMockTestingT(t)
_ = setup(t, func(tc *TestConfig) { _ = setup(t, func(tc *TestConfig) {
@@ -866,27 +866,27 @@ func TestPlanCommandRunner_SilenceFlagsClearsPendingStatus(t *testing.T) {
// This is the key test: when both conditions are true: // This is the key test: when both conditions are true:
// 1. Silence flags are enabled // 1. Silence flags are enabled
// 2. No projects are found // 2. No projects are found
// We should STILL update the status to clear any pending state // We should NOT set any VCS status at all
// The plan runner is now configured with silence flags // The plan runner is now configured with silence flags
// When it finds no projects, it should clear the pending status // When it finds no projects, it should not set any VCS status
// even though silence is enabled // because silence means no status checks at all
// Run through the plan command (which will internally check for projects) // Run through the plan command (which will internally check for projects)
cmd := &events.CommentCommand{Name: command.Plan} cmd := &events.CommentCommand{Name: command.Plan}
planCommandRunner.Run(ctx, cmd) planCommandRunner.Run(ctx, cmd)
// CRITICAL VERIFICATION: With the fix, even with silence flags enabled, // CRITICAL VERIFICATION: With silence flags enabled, no status should be set at all
// we should update the status to Success with 0/0 to clear pending state // This prevents any VCS status checks from being created (issue #5389)
// This prevents PRs from being stuck in pending state (issue #5389) // The silence flags mean "don't create any status checks"
commitUpdater.VerifyWasCalled(AtLeast(1)).UpdateCombinedCount( commitUpdater.VerifyWasCalled(Never()).UpdateCombinedCount(
Any[logging.SimpleLogging](), Any[logging.SimpleLogging](),
Any[models.Repo](), Any[models.Repo](),
Any[models.PullRequest](), Any[models.PullRequest](),
Eq[models.CommitStatus](models.SuccessCommitStatus), Any[models.CommitStatus](),
Eq[command.Name](command.Plan), Any[command.Name](),
Eq(0), Any[int](),
Eq(0), Any[int](),
) )
}) })
} }