Skip to content

Commit

Permalink
inline some code to see if it helps with the duplicate code warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bhamail committed Sep 17, 2024
1 parent 30eea51 commit bdb1472
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,10 @@ func TestWithFullEnvironment(t *testing.T) {
&issuesMock,
nil,
)
prEvent := webhook.PullRequestPayload{}

mockDB, logger := setupMockDB(t, true)
mockDB.hasAuthorSignedLogin = authors[0]

err := HandlePullRequest(logger, mockDB, prEvent, 0, "")
err := HandlePullRequest(logger, mockDB, webhook.PullRequestPayload{}, 0, "")
assert.EqualError(t, err, forcedError.Error())
})

Expand All @@ -320,12 +318,10 @@ func TestWithFullEnvironment(t *testing.T) {
&repositoriesMock,
)

prEvent := webhook.PullRequestPayload{}

mockDB, logger := setupMockDB(t, true)
mockDB.hasAuthorSignedLogin = authors[0]

err := HandlePullRequest(logger, mockDB, prEvent, 0, "")
err := HandlePullRequest(logger, mockDB, webhook.PullRequestPayload{}, 0, "")
assert.EqualError(t, err, forcedError.Error())
})

Expand All @@ -344,13 +340,11 @@ func TestWithFullEnvironment(t *testing.T) {
}
GHImpl = getGHMock(getMockRepositoryCommits(authors, true), &issuesMock, &repositoriesMock)

prEvent := webhook.PullRequestPayload{}

mockDB, logger := setupMockDB(t, true)
mockDB.hasAuthorSignedLogin = authors[0]
mockDB.removePRsEvalInfo = &types.EvaluationInfo{}

err := HandlePullRequest(logger, mockDB, prEvent, 0, "")
err := HandlePullRequest(logger, mockDB, webhook.PullRequestPayload{}, 0, "")
assert.NoError(t, err)
})

Expand All @@ -365,9 +359,8 @@ func TestWithFullEnvironment(t *testing.T) {

// GHImpl = getGHMock(nil, nil, setupMockRepositoriesService(t, false))

prEvent := webhook.PullRequestPayload{}
mockDB, logger := setupMockDB(t, true)
err := HandlePullRequest(logger, mockDB, prEvent, 0, "")
err := HandlePullRequest(logger, mockDB, webhook.PullRequestPayload{}, 0, "")
assert.EqualError(t, err, forcedError.Error())
})

Expand All @@ -389,19 +382,16 @@ func TestWithFullEnvironment(t *testing.T) {
}()
authors := []string{"john", "doe"}
GHImpl = getGHMock(getMockRepositoryCommits(authors, true), nil, nil)
prEvent := webhook.PullRequestPayload{}
mockDB, logger := setupMockDB(t, false)
err := HandlePullRequest(logger, mockDB, prEvent, 0, "")
err := HandlePullRequest(logger, mockDB, webhook.PullRequestPayload{}, 0, "")
assert.NoError(t, err)
})

t.Run("TestHandlePullRequestListCommitsUnsignedCommit", func(t *testing.T) {
authors := []string{"john", "doe"}
GHImpl = getGHMock(getMockRepositoryCommits(authors, false), nil, nil)
prEvent := webhook.PullRequestPayload{}

mockDB, logger := setupMockDB(t, false)
err := HandlePullRequest(logger, mockDB, prEvent, 0, "")
err := HandlePullRequest(logger, mockDB, webhook.PullRequestPayload{}, 0, "")
assert.NoError(t, err)
})
}
Expand Down

0 comments on commit bdb1472

Please sign in to comment.