From 161b7b0628bb1583732b8964758c86df1a6a82c1 Mon Sep 17 00:00:00 2001 From: Shawna Monero Date: Wed, 10 Jul 2024 09:53:16 -0700 Subject: [PATCH] fix tests --- server/legacy/events/policy_filter_test.go | 74 ------------------- .../lyft/command/feature_runner_test.go | 9 --- 2 files changed, 83 deletions(-) diff --git a/server/legacy/events/policy_filter_test.go b/server/legacy/events/policy_filter_test.go index ce076e3c7..854806cf0 100644 --- a/server/legacy/events/policy_filter_test.go +++ b/server/legacy/events/policy_filter_test.go @@ -45,32 +45,6 @@ func TestFilter_Approved(t *testing.T) { assert.Empty(t, filteredPolicies) } -func TestFilter_DismissalBlockedByFeatureAllocator(t *testing.T) { - reviewFetcher := &mockReviewFetcher{ - reviews: []*github.PullRequestReview{ - { - User: &github.User{Login: github.String(ownerA)}, - }, - }, - } - teamFetcher := &mockTeamMemberFetcher{ - members: []string{ownerA}, - } - reviewDismisser := &mockReviewDismisser{} - failedPolicies := []valid.PolicySet{ - {Name: policyName, Owner: policyOwner}, - } - - policyFilter := NewApprovedPolicyFilter(reviewFetcher, reviewDismisser, teamFetcher, &testFeatureAllocator{Enabled: true}, failedPolicies, logging.NewNoopCtxLogger(t)) - filteredPolicies, err := policyFilter.Filter(context.Background(), 0, models.Repo{}, 0, command.AutoTrigger, failedPolicies) - assert.NoError(t, err) - assert.False(t, reviewFetcher.listUsernamesIsCalled) - assert.False(t, reviewFetcher.listApprovalsIsCalled) - assert.False(t, teamFetcher.isCalled) - assert.False(t, reviewDismisser.isCalled) - assert.Equal(t, failedPolicies, filteredPolicies) -} - func TestFilter_NoFailedPolicies(t *testing.T) { reviewFetcher := &mockReviewFetcher{ approvers: []string{ownerB}, @@ -111,26 +85,6 @@ func TestFilter_FailedListLatestApprovalUsernames(t *testing.T) { assert.Equal(t, failedPolicies, filteredPolicies) } -func TestFilter_FailedListApprovalReviews(t *testing.T) { - reviewFetcher := &mockReviewFetcher{ - listApprovalsError: assert.AnError, - } - teamFetcher := &mockTeamMemberFetcher{} - reviewDismisser := &mockReviewDismisser{} - failedPolicies := []valid.PolicySet{ - {Name: policyName, Owner: policyOwner}, - } - - policyFilter := NewApprovedPolicyFilter(reviewFetcher, reviewDismisser, teamFetcher, &testFeatureAllocator{}, failedPolicies, logging.NewNoopCtxLogger(t)) - filteredPolicies, err := policyFilter.Filter(context.Background(), 0, models.Repo{}, 0, command.CommentTrigger, failedPolicies) - assert.Error(t, err) - assert.False(t, reviewFetcher.listUsernamesIsCalled) - assert.True(t, reviewFetcher.listApprovalsIsCalled) - assert.False(t, reviewDismisser.isCalled) - assert.False(t, teamFetcher.isCalled) - assert.Equal(t, failedPolicies, filteredPolicies) -} - func TestFilter_FailedTeamMemberFetch(t *testing.T) { reviewFetcher := &mockReviewFetcher{ approvers: []string{ownerB}, @@ -153,34 +107,6 @@ func TestFilter_FailedTeamMemberFetch(t *testing.T) { assert.Equal(t, failedPolicies, filteredPolicies) } -func TestFilter_FailedDismiss(t *testing.T) { - reviewFetcher := &mockReviewFetcher{ - reviews: []*github.PullRequestReview{ - { - User: &github.User{Login: github.String(ownerB)}, - }, - }, - } - reviewDismisser := &mockReviewDismisser{ - error: assert.AnError, - } - teamFetcher := &mockTeamMemberFetcher{ - members: []string{ownerB}, - } - failedPolicies := []valid.PolicySet{ - {Name: policyName, Owner: policyOwner}, - } - - policyFilter := NewApprovedPolicyFilter(reviewFetcher, reviewDismisser, teamFetcher, &testFeatureAllocator{}, failedPolicies, logging.NewNoopCtxLogger(t)) - filteredPolicies, err := policyFilter.Filter(context.Background(), 0, models.Repo{}, 0, command.AutoTrigger, failedPolicies) - assert.Error(t, err) - assert.False(t, reviewFetcher.listUsernamesIsCalled) - assert.True(t, reviewFetcher.listApprovalsIsCalled) - assert.True(t, teamFetcher.isCalled) - assert.True(t, reviewDismisser.isCalled) - assert.Equal(t, failedPolicies, filteredPolicies) -} - type mockReviewFetcher struct { approvers []string listUsernamesIsCalled bool diff --git a/server/legacy/lyft/command/feature_runner_test.go b/server/legacy/lyft/command/feature_runner_test.go index 1624bf8b8..c3cee8ff7 100644 --- a/server/legacy/lyft/command/feature_runner_test.go +++ b/server/legacy/lyft/command/feature_runner_test.go @@ -374,15 +374,6 @@ func TestPlatformModeProjectRunner_policyCheck(t *testing.T) { expectedPolicyCheckResult: expectedResult, }, }, - { - description: "not allocated and platform mode enabled", - shouldAllocate: false, - workflowModeType: valid.PlatformWorkflowMode, - platformRunner: &testRunner{}, - prModeRunner: &testRunner{ - expectedPolicyCheckResult: expectedResult, - }, - }, } for _, c := range cases {