Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change message for when request is not approved to be more accurate #3744

Merged
merged 4 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions server/events/command_requirement_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (a *DefaultCommandRequirementHandler) ValidatePlanProject(repoDir string, c
switch req {
case raw.ApprovedRequirement:
if !ctx.PullReqStatus.ApprovalStatus.IsApproved {
return "Pull request must be approved by at least one person other than the author before running plan.", nil
return "Pull request must be approved according to the project's approval rules before running plan.", nil
}
case raw.MergeableRequirement:
if !ctx.PullReqStatus.Mergeable {
Expand All @@ -43,7 +43,7 @@ func (a *DefaultCommandRequirementHandler) ValidateApplyProject(repoDir string,
switch req {
case raw.ApprovedRequirement:
if !ctx.PullReqStatus.ApprovalStatus.IsApproved {
return "Pull request must be approved by at least one person other than the author before running apply.", nil
return "Pull request must be approved according to the project's approval rules before running apply.", nil
}
// this should come before mergeability check since mergeability is a superset of this check.
case valid.PoliciesPassedCommandReq:
Expand All @@ -70,7 +70,7 @@ func (a *DefaultCommandRequirementHandler) ValidateImportProject(repoDir string,
switch req {
case raw.ApprovedRequirement:
if !ctx.PullReqStatus.ApprovalStatus.IsApproved {
return "Pull request must be approved by at least one person other than the author before running import.", nil
return "Pull request must be approved according to the project's approval rules before running import.", nil
}
case raw.MergeableRequirement:
if !ctx.PullReqStatus.Mergeable {
Expand Down
6 changes: 3 additions & 3 deletions server/events/command_requirement_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestAggregateApplyRequirements_ValidatePlanProject(t *testing.T) {
ApprovalStatus: models.ApprovalStatus{IsApproved: false},
},
},
wantFailure: "Pull request must be approved by at least one person other than the author before running plan.",
wantFailure: "Pull request must be approved according to the project's approval rules before running plan.",
wantErr: assert.NoError,
},
{
Expand Down Expand Up @@ -142,7 +142,7 @@ func TestAggregateApplyRequirements_ValidateApplyProject(t *testing.T) {
ApprovalStatus: models.ApprovalStatus{IsApproved: false},
},
},
wantFailure: "Pull request must be approved by at least one person other than the author before running apply.",
wantFailure: "Pull request must be approved according to the project's approval rules before running apply.",
wantErr: assert.NoError,
},
{
Expand Down Expand Up @@ -249,7 +249,7 @@ func TestAggregateApplyRequirements_ValidateImportProject(t *testing.T) {
ApprovalStatus: models.ApprovalStatus{IsApproved: false},
},
},
wantFailure: "Pull request must be approved by at least one person other than the author before running import.",
wantFailure: "Pull request must be approved according to the project's approval rules before running import.",
wantErr: assert.NoError,
},
{
Expand Down
4 changes: 2 additions & 2 deletions server/events/project_command_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func TestDefaultProjectCommandRunner_ApplyNotApproved(t *testing.T) {
When(mockWorkingDir.GetWorkingDir(ctx.BaseRepo, ctx.Pull, ctx.Workspace)).ThenReturn(tmp, nil)

res := runner.Apply(ctx)
Equals(t, "Pull request must be approved by at least one person other than the author before running apply.", res.Failure)
Equals(t, "Pull request must be approved according to the project's approval rules before running apply.", res.Failure)
}

// Test that if mergeable is required and the PR isn't mergeable we give an error.
Expand Down Expand Up @@ -676,7 +676,7 @@ func TestDefaultProjectCommandRunner_Import(t *testing.T) {
IsApproved: false,
},
},
expFailure: "Pull request must be approved by at least one person other than the author before running import.",
expFailure: "Pull request must be approved according to the project's approval rules before running import.",
},
}

Expand Down