Skip to content

Commit 375c536

Browse files
committed
tests: accommodate for recent changes
We now require the events to originate from the GitForWindowsHelper GitHub App, or from a user with write permissions to the repository. Naturally, these additional checks require a bit more metadata in the mocked events. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent f0642aa commit 375c536

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

__tests__/index.test.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ afterEach(() => {
189189
})
190190

191191
const makeContext = (body, headers) => {
192+
body = {
193+
app: {
194+
slug: 'gitforwindowshelper'
195+
},
196+
sender: {
197+
login: 'gitforwindowshelper[bot]'
198+
},
199+
...body
200+
}
192201
const rawBody = JSON.stringify(body)
193202
const sha256 = crypto.createHmac('sha256', process.env['GITHUB_WEBHOOK_SECRET']).update(rawBody).digest('hex')
194203
return {
@@ -421,6 +430,9 @@ The workflow run [was started](dispatched-workflow-updpkgsums.yml).`
421430
let mockQueueCheckRun = jest.fn(() => 'check-run-id')
422431
let mockUpdateCheckRun = jest.fn()
423432
let mockListCheckRunsForCommit = jest.fn((_context, _token, _owner, _repo, rev, checkRunName) => {
433+
const app = {
434+
slug: 'gitforwindowshelper'
435+
}
424436
if (rev === 'this-will-be-rc2') {
425437
const id = {
426438
'git-artifacts-x86_64': 8664,
@@ -432,7 +444,7 @@ let mockListCheckRunsForCommit = jest.fn((_context, _token, _owner, _repo, rev,
432444
summary: 'Build Git -rc2 artifacts from commit this-will-be-rc2 (tag-git run #987)',
433445
text: `For details, see [this run](https://github.com/git-for-windows/git-for-windows-automation/actions/runs/${id})`
434446
}
435-
return [{ id, status: 'completed', conclusion: 'success', output }]
447+
return [{ id, status: 'completed', conclusion: 'success', output, app }]
436448
}
437449
if (rev === '0c796d3013a57e8cc894c152f0200107226e5dd1') {
438450
const id = {
@@ -456,7 +468,8 @@ let mockListCheckRunsForCommit = jest.fn((_context, _token, _owner, _repo, rev,
456468
title: 'Tag Git -rc1½',
457469
summary: `Tag Git -rc1½ @${rev}`,
458470
text: 'For details, see [this run](https://github.com/git-for-windows/git-for-windows-automation/actions/runs/341).'
459-
}
471+
},
472+
app,
460473
}]
461474
return []
462475
}
@@ -935,7 +948,9 @@ test('a completed `release-git` run updates the `main` branch in git-for-windows
935948
workflow_run: {
936949
id: 54321,
937950
path: '.github/workflows/release-git.yml',
938-
conclusion: 'success'
951+
conclusion: 'success',
952+
event: 'workflow_dispatch',
953+
head_branch: 'main',
939954
}
940955
}, {
941956
'x-github-event': 'workflow_run'

0 commit comments

Comments
 (0)