Skip to content
Merged
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
8 changes: 2 additions & 6 deletions GitGitGadget/index.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,6 @@ module.exports = async (context, req) =>{
status: 403,
body: 'Not a valid GitHub webhook: ' + e,
};
context.done();
return;
}

Expand DownExpand Up@@ -112,7 +111,6 @@ module.exports = async (context, req) =>{
context.res ={
body: `Not a command: '${comment.body}'`,
};
context.done();
return;
}

Expand All@@ -131,12 +129,10 @@ module.exports = async (context, req) =>{
};
}
} catch (e){
context.log('Caught exception ' + e);
context.log('Caught exception ', e);
context.res ={
status: 500,
body: 'Caught an error: ' + e,
body: `Caught an error: ${e.message || JSON.stringify(e, null, 2)}`,
};
}

context.done();
};
12 changes: 6 additions & 6 deletions __tests__/index.test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,7 +49,7 @@ test('reject requests other than webhook payloads', async () =>{
body: `Not a valid GitHub webhook: Error: ${message}`,
status: 403
})
expect(context.done).toHaveBeenCalledTimes(1)
expect(context.done).not.toHaveBeenCalled()
}

await expectInvalidWebhook('Unexpected content type: text/plain')
Expand DownExpand Up@@ -142,7 +142,7 @@ const testIssueComment = (comment, repoOwner, fn) =>{
try{
expect(await index(context, context.req)).toBeUndefined()
await fn(context)
expect(context.done).toHaveBeenCalledTimes(1)
expect(context.done).not.toHaveBeenCalled()
} catch (e){
context.log.mock.calls.forEach(e => console.log(e[0]))
throw e;
Expand All@@ -151,7 +151,7 @@ const testIssueComment = (comment, repoOwner, fn) =>{
}

testIssueComment('/test', async (context) =>{
expect(context.done).toHaveBeenCalledTimes(1)
expect(context.done).not.toHaveBeenCalled()
expect(context.res).toEqual({
body: 'Okay, triggered <the URL to the workflow handle-pr-comment.yml run on main with inputs{"pr-comment-url":"https://github.com/gitgitgadget/git/pull/1886743660"}>!'
})
Expand All@@ -160,7 +160,7 @@ testIssueComment('/test', async (context) =>{
})

testIssueComment('/verify-repository', 'nope', (context) =>{
expect(context.done).toHaveBeenCalledTimes(1)
expect(context.done).not.toHaveBeenCalled()
expect(context.res).toEqual({
body: 'Refusing to work on a repository other than gitgitgadget/git or git/git',
'status': 403,
Expand All@@ -178,7 +178,7 @@ const testWebhookPayload = (testLabel, gitHubEvent, payload, fn) =>{
try{
expect(await index(context, context.req)).toBeUndefined()
await fn(context)
expect(context.done).toHaveBeenCalledTimes(1)
expect(context.done).not.toHaveBeenCalled()
} catch (e){
context.log.mock.calls.forEach(e => console.log(e[0]))
throw e;
Expand DownExpand Up@@ -305,4 +305,4 @@ testWebhookPayload('react to PR push', 'pull_request',{
'pr-url': 'https://github.com/gitgitgadget/git/pull/1956',
}
])
})
})