@@ -3,6 +3,10 @@ const crypto = require('crypto')
33const stream = require ( 'stream' )
44const https = require ( 'https' )
55
6+ afterEach ( ( ) => {
7+ jest . clearAllMocks ( ) ;
8+ } )
9+
610process . env [ 'GITHUB_WEBHOOK_SECRET' ] = 'for-testing'
711process . env [ 'GITGITGADGET_TRIGGER_TOKEN' ] = 'token-for-testing'
812
@@ -84,8 +88,12 @@ const makeContext = (body, headers) => {
8488 }
8589}
8690
87- const testIssueComment = ( comment , fn ) => {
88- const repoOwner = 'gitgitgadget'
91+ const testIssueComment = ( comment , repoOwner , fn ) => {
92+ if ( ! fn ) {
93+ fn = repoOwner
94+ repoOwner = undefined
95+ }
96+ repoOwner ||= 'gitgitgadget'
8997 const number = 0x70756c6c
9098 const context = makeContext ( {
9199 action : 'created' ,
@@ -140,3 +148,13 @@ testIssueComment('/test', async (context) => {
140148 } )
141149 expect ( mockRequest . end ) . toHaveBeenCalledTimes ( 1 )
142150} )
151+
152+ testIssueComment ( '/verify-repository' , 'nope' , ( context ) => {
153+ expect ( context . done ) . toHaveBeenCalledTimes ( 1 )
154+ expect ( context . res ) . toEqual ( {
155+ body : 'Refusing to work on a repository other than gitgitgadget/git or git/git' ,
156+ 'status' : 403 ,
157+ } )
158+ expect ( mockRequest . write ) . not . toHaveBeenCalled ( )
159+ expect ( mockRequest . end ) . not . toHaveBeenCalled ( )
160+ } )
0 commit comments