Skip to content

Commit 853883f

Browse files
committed
Corrected handler test
1 parent c2c7bb3 commit 853883f

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

serve.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ async function setAccessToken() {
8585

8686
///////////////////// MAIN APP ENTRY POINT /////////////////////
8787

88+
/**
89+
* Register invalid Github POST requests to handler via /github endpoint.
90+
* Failed spoof attempts may end up here but most likely it will be unsupported webhook events.
91+
*/
92+
handler.on('error', function (err) {
93+
console.log('Error:', err.message);
94+
});
95+
8896
/**
8997
* Callback to deal with POST requests from /github endpoint, authenticates as app and passes on
9098
* request to handler.
@@ -102,14 +110,6 @@ srv.post('/github', async (req, res, next) => {
102110
handler(req, res, () => res.end('ok'));
103111
});
104112

105-
/**
106-
* Register invalid Github POST requests to handler via /github endpoint.
107-
* Failed spoof attempts may end up here but most likely it will be unsupported webhook events.
108-
*/
109-
handler.on('error', function (err) {
110-
console.log('Error:', err.message);
111-
});
112-
113113

114114
///////////////////// STATUS DETAILS /////////////////////
115115

test/serve.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ describe('srv github/', () => {
745745
});
746746
});
747747

748-
it('expect error caught', () => {
748+
it('expect error caught', (done) => {
749749
scope.get(`/repos/${process.env.REPO_OWNER}/${process.env.REPO_NAME}/installation`)
750750
.reply(201, {id: APP_ID});
751751
scope.post(`/app/installations/${APP_ID}/access_tokens`)
@@ -761,13 +761,14 @@ describe('srv github/', () => {
761761
request(srv)
762762
.post(`/github`) // trailing slash essential
763763
.set({
764-
'X-GitHub-Event': 'issues',
764+
'X-GitHub-Event': 'check_suite',
765765
'x-github-hook-installation-target-id': process.env.GITHUB_APP_IDENTIFIER,
766766
'X-Hub-Signature': {'sha': null},
767767
'X-GitHub-Delivery': '72d3162e-cc78-11e3-81ab-4c9367dc0958'
768768
})
769769
.end(function (err) {
770770
expect(err).is.null; // Should have caught error
771+
done()
771772
});
772773
});
773774

0 commit comments

Comments
 (0)