Skip to content

Commit

Permalink
Create tests for requiredAuthorRole
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsiqueira committed Aug 24, 2020
1 parent dbfb199 commit b32c903
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/conditions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import blockingTitle from './blockingTitle'
import maximumChangesRequested from './maximumChangesRequested'
import mergeable from './mergeable'
import minimumApprovals from './minimumApprovals'
import requiredAuthorRole from './requiredAuthorRole'
import requiredReviewers from './requiredReviewers'
import open from './open'
// import requiredChecks from './requiredChecks'
Expand All @@ -22,6 +23,7 @@ export const conditions = {
maximumChangesRequested,
mergeable,
minimumApprovals,
requiredAuthorRole,
requiredReviewers,
open,
// requiredChecks,
Expand Down
58 changes: 58 additions & 0 deletions test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,64 @@ it('to merge when one rule and the global configuration passes', async () => {
expect(github.pulls.merge).toHaveBeenCalled()
})

it('to merge when the role of the pull request author is satisfied, and fail otherwise', async () => {
const config = `
rules:
- requiredAuthorRole: OWNER
minApprovals:
OWNER: 1
`

const pullRequestInfo = createPullRequestInfo({
authorAssociation: CommentAuthorAssociation.MEMBER,
reviews: {
nodes: [
approvedReview({
authorAssociation: CommentAuthorAssociation.OWNER
})
]
},
commits: createCommitsWithCheckSuiteWithCheckRun({
checkRun: successCheckRun
})
})

const github = createGithubApiFromPullRequestInfo({
pullRequestInfo,
config
})

const app = createApplication({
appFn,
logger: createEmptyLogger(),
github
})

await app.receive(
createPullRequestOpenedEvent({
owner: 'bobvanderlinden',
repo: 'probot-auto-merge',
number: 1
})
)

// Only 1 review and PR is not from OWNER
expect(github.pulls.merge).not.toHaveBeenCalled()

pullRequestInfo.authorAssociation = CommentAuthorAssociation.OWNER

await app.receive(
createPullRequestOpenedEvent({
owner: 'bobvanderlinden',
repo: 'probot-auto-merge',
number: 2
})
)

// Only 1 review but PR is from OWNER
expect(github.pulls.merge).toHaveBeenCalled()
})

it('to report error when processing pull request results in error', async () => {
const Raven = require('raven')
const captureException = jest.fn()
Expand Down

0 comments on commit b32c903

Please sign in to comment.