From c1eaee9f50c32903369de7123012f0edcdfb4671 Mon Sep 17 00:00:00 2001 From: Shawna Monero Date: Wed, 10 Jul 2024 09:57:17 -0700 Subject: [PATCH] fix tests --- server/legacy/events/policy_filter.go | 17 ------- server/legacy/events/vcs/github_client.go | 58 ----------------------- server/legacy/events/vcs/inject.go | 4 +- server/legacy/events/vcs/inject_lyft.go | 2 +- 4 files changed, 3 insertions(+), 78 deletions(-) diff --git a/server/legacy/events/policy_filter.go b/server/legacy/events/policy_filter.go index 676c54b39..d768b8856 100644 --- a/server/legacy/events/policy_filter.go +++ b/server/legacy/events/policy_filter.go @@ -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) diff --git a/server/legacy/events/vcs/github_client.go b/server/legacy/events/vcs/github_client.go index 52ccf4b60..adc686478 100644 --- a/server/legacy/events/vcs/github_client.go +++ b/server/legacy/events/vcs/github_client.go @@ -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 @@ -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 @@ -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 diff --git a/server/legacy/events/vcs/inject.go b/server/legacy/events/vcs/inject.go index 1ac7ec636..354a7f5f0 100644 --- a/server/legacy/events/vcs/inject.go +++ b/server/legacy/events/vcs/inject.go @@ -3,7 +3,7 @@ package vcs // Declare all package dependencies here func NewPullMergeabilityChecker(vcsStatusPrefix string) MergeabilityChecker { - statusFilters := newValidStatusFilters(vcsStatusPrefix) + statusFilters := newValidStatusFilters() checksFilters := newValidChecksFilters(vcsStatusPrefix) return &PullMergeabilityChecker{ @@ -11,7 +11,7 @@ func NewPullMergeabilityChecker(vcsStatusPrefix string) MergeabilityChecker { } } -func newValidStatusFilters(vcsStatusPrefix string) []ValidStatusFilter { +func newValidStatusFilters() []ValidStatusFilter { return []ValidStatusFilter{ SuccessStateFilter, } diff --git a/server/legacy/events/vcs/inject_lyft.go b/server/legacy/events/vcs/inject_lyft.go index 116160954..81e82c663 100644 --- a/server/legacy/events/vcs/inject_lyft.go +++ b/server/legacy/events/vcs/inject_lyft.go @@ -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)