Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smonero committed Jul 10, 2024
1 parent 161b7b0 commit c1eaee9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 78 deletions.
17 changes: 0 additions & 17 deletions server/legacy/events/policy_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,6 @@ func (p *ApprovedPolicyFilter) Filter(ctx context.Context, installationToken int
return filteredFailedPolicies, nil
}

func (p *ApprovedPolicyFilter) approverIsOwner(ctx context.Context, installationToken int64, approval *gh.PullRequestReview) (bool, error) {
if approval.GetUser() == nil {
return false, errors.New("failed to identify approver")
}
reviewers := []string{approval.GetUser().GetLogin()}
for _, policy := range p.policies {
isOwner, err := p.reviewersContainsPolicyOwner(ctx, installationToken, reviewers, policy)
if err != nil {
return false, errors.Wrap(err, "validating policy approval")
}
if isOwner {
return true, nil
}
}
return false, nil
}

func (p *ApprovedPolicyFilter) reviewersContainsPolicyOwner(ctx context.Context, installationToken int64, reviewers []string, policy valid.PolicySet) (bool, error) {
// fetch owners from GH team
owners, err := p.teamMemberFetcher.ListTeamMembers(ctx, installationToken, policy.Owner)
Expand Down
58 changes: 0 additions & 58 deletions server/legacy/events/vcs/github_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,6 @@ import (
"github.com/shurcooL/githubv4"
)

var projectCommandTemplateWithLogs = `
| **Command Name** | **Project** | **Workspace** | **Status** | **Logs** |
| - | - | - | - | - |
| %s | {%s} | {%s} | {%s} | %s |
`

var projectCommandTemplate = `
| **Command Name** | **Project** | **Workspace** | **Status** |
| - | - | - | - |
| %s | {%s} | {%s} | {%s} |
`

var commandTemplate = `
| **Command Name** | **Status** |
| - | - |
| %s | {%s} |
:information_source: Visit the checkrun for the root in the navigation panel on your left to view logs and details on the operation.
`

var commandTemplateWithCount = `
| **Command Name** | **Num Total** | **Num Success** | **Status** |
| - | - | - | - |
| %s | {%s} | {%s} | {%s} |
:information_source: Visit the checkrun for the root in the navigation panel on your left to view logs and details on the operation.
`

// github checks conclusion
type ChecksConclusion int //nolint:golint // avoiding refactor while adding linter action

Expand Down Expand Up @@ -119,8 +89,6 @@ func (e CheckStatus) String() string {
// by GitHub.
const (
maxCommentLength = 65536
// Reference: https://github.com/github/docs/issues/3765
maxChecksOutputLength = 65535
)

// allows for custom handling of github 404s
Expand Down Expand Up @@ -500,32 +468,6 @@ func (g *GithubClient) UpdateStatus(ctx context.Context, request types.UpdateSta
return "", nil
}

// Github Checks uses Status and Conclusion to report status of the check run. Need to map models.VcsStatus to Status and Conclusion
// Status -> queued, in_progress, completed
// Conclusion -> failure, neutral, cancelled, timed_out, or action_required. (Optional. Required if you provide a status of "completed".)
func (g *GithubClient) resolveChecksStatus(state models.VCSStatus) (string, string) {
status := Queued
conclusion := Neutral

switch state {
case models.SuccessVCSStatus:
status = Completed
conclusion = Success

case models.PendingVCSStatus:
status = InProgress

case models.FailedVCSStatus:
status = Completed
conclusion = Failure

case models.QueuedVCSStatus:
status = Queued
}

return status.String(), conclusion.String()
}

// MarkdownPullLink specifies the string used in a pull request comment to reference another pull request.
func (g *GithubClient) MarkdownPullLink(pull models.PullRequest) (string, error) {
return fmt.Sprintf("#%d", pull.Num), nil
Expand Down
4 changes: 2 additions & 2 deletions server/legacy/events/vcs/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package vcs
// Declare all package dependencies here

func NewPullMergeabilityChecker(vcsStatusPrefix string) MergeabilityChecker {
statusFilters := newValidStatusFilters(vcsStatusPrefix)
statusFilters := newValidStatusFilters()
checksFilters := newValidChecksFilters(vcsStatusPrefix)

return &PullMergeabilityChecker{
supplementalChecker: newSupplementalMergeabilityChecker(statusFilters, checksFilters),
}
}

func newValidStatusFilters(vcsStatusPrefix string) []ValidStatusFilter {
func newValidStatusFilters() []ValidStatusFilter {
return []ValidStatusFilter{
SuccessStateFilter,
}
Expand Down
2 changes: 1 addition & 1 deletion server/legacy/events/vcs/inject_lyft.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/runatlantis/atlantis/server/legacy/events/vcs/lyft"
// Declare all lyft package dependencies here

func NewLyftPullMergeabilityChecker(vcsStatusPrefix string) MergeabilityChecker {
statusFilters := newValidStatusFilters(vcsStatusPrefix)
statusFilters := newValidStatusFilters()
statusFilters = append(statusFilters, lyft.NewSQFilter())

checksFilters := newValidChecksFilters(vcsStatusPrefix)
Expand Down

0 comments on commit c1eaee9

Please sign in to comment.