Skip to content

Commit

Permalink
fix: Change message for when request is not approved to be more accur…
Browse files Browse the repository at this point in the history
…ate (#3744)

* Change message for when request is not approved

* Updates

* Fix

* Fix tests
  • Loading branch information
lukemassa authored Sep 6, 2023
1 parent 2094e51 commit 6142b46
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
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

0 comments on commit 6142b46

Please sign in to comment.