Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions __tests__/plugins/blunderbuss.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,20 @@ describe('blunderbuss handler', () => {
await expect(observePull.notCalled()).resolves.toBe('not called')
})

it('fails when the review request is refused', async () => {
it('fails when the review request is refused, without retrying each reviewer alone', async () => {
serveConfig()
servePr(owners, ['sdk/x.go'])
observeRequestReviewers(500)
const calls: string[][] = []
server.use(http.post(`${repo}/pulls/1/requested_reviewers`, async ({ request }) => {
calls.push((await request.json() as { reviewers: string[] }).reviewers)
return new Response(JSON.stringify({ message: 'boom' }), { status: 500, headers: { 'Content-Type': 'application/json' } })
}))
const warning = vi.spyOn(core, 'warning').mockImplementation(() => {})

await expect(blunderbuss(prEvent('opened'))).rejects.toThrow(/could not request reviewers: .*boom/)
await expect(blunderbuss(prEvent('opened'), first)).rejects.toThrow(/could not request reviewers: .*boom/)
// only a 422 means one login spoiled the batch; any other status is reported as is
expect(calls).toEqual([['alice', 'bob']])
expect(warning).not.toHaveBeenCalled()
})

it('when GitHub refuses the batch with a 422, requests each reviewer alone and keeps the ones it accepts', async () => {
Expand Down
8 changes: 5 additions & 3 deletions __tests__/plugins/requireMatchingLabel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ interface Writes {
deleteComment: utils.ObserveRequest
}

function serveIssue(labels: string[], comments: { id: number, body: string, user: { login: string, type: string } }[] = []): Writes {
function serveIssue(labels: string[], comments: { id: number, body: string, user: { login: string, type: string } | null }[] = []): Writes {
const writes: Writes = {
addLabels: new utils.ObserveRequest(),
removeLabel: new utils.ObserveRequest(),
Expand Down Expand Up @@ -116,6 +116,8 @@ const botComment = { id: 11, body: `Please add a kind label.\n\n${marker}`, user
const humanComment = { id: 12, body: `I pasted the marker by hand ${marker}`, user: { login: 'Codertocat', type: 'User' } }
// another GitHub App's bot: `type: 'Bot'` without the github-actions login
const appBotComment = { id: 13, body: `Please add a kind label.\n\n${marker}`, user: { login: 'other-app[bot]', type: 'Bot' } }
// a comment whose author deleted their account: GitHub answers `user: null`
const ghostComment = { id: 14, body: `Please add a kind label.\n\n${marker}`, user: null }

describe('evaluate', () => {
it.each([
Expand Down Expand Up @@ -264,9 +266,9 @@ describe('requireMatchingLabel handler', () => {
expect(setFailed).not.toHaveBeenCalled()
})

it('deletes the marker comment of another app bot but not the human copy of the marker', async () => {
it('deletes the marker comment of another app bot but not the human or authorless copies of the marker', async () => {
serveRules([kindRule])
serveIssue(['kind/bug', 'needs-kind'], [humanComment, appBotComment])
serveIssue(['kind/bug', 'needs-kind'], [humanComment, appBotComment, ghostComment])
const deleted: string[] = []
server.use(http.delete(`${repo}/issues/comments/:id`, ({ params }) => {
deleted.push(String(params.id))
Expand Down
Loading