@@ -61,7 +61,7 @@ test('handles feed entries without titles', async () => {
6161 const date = '2021-06-19T01:01:29+12:00'
6262 mockHTTPSGet . __RETURN__ = `<feed xmlns="http://www.w3.org/2005/Atom"><entry><published>${ date } </published><content type="html">TBD</content></entry></feed>`
6363 core . __INPUTS__ [ 'max-age' ] = '9999d'
64- octokit . rest . issues . listForRepo . mockReturnValueOnce ( { data : [ ] } )
64+ octokit . rest . issues . listForRepo . mockReturnValueOnce ( { status : 200 , data : [ ] } )
6565 await run ( )
6666
6767 expect ( https . get ) . toHaveBeenCalledTimes ( 1 )
@@ -105,7 +105,7 @@ Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;<
105105 </entry>
106106</feed>
107107`
108- octokit . rest . issues . listForRepo . mockReturnValueOnce ( { data : [ ] } )
108+ octokit . rest . issues . listForRepo . mockReturnValueOnce ( { status : 200 , data : [ ] } )
109109 await run ( )
110110
111111 expect ( octokit . rest . issues . create ) . toHaveBeenCalledWith ( {
@@ -166,7 +166,7 @@ test('curl -rc versions', async () => {
166166 <media:thumbnail height="30" width="30" url="https://avatars.githubusercontent.com/u/177011?s=60&v=4"/>
167167 </entry>
168168</feed>`
169- octokit . rest . issues . listForRepo . mockReturnValueOnce ( { data : [ ] } )
169+ octokit . rest . issues . listForRepo . mockReturnValueOnce ( { status : 200 , data : [ ] } )
170170 Object . assign ( core . __INPUTS__ , {
171171 'max-age' : '9999d' ,
172172 prefix : '[New curl version]' ,
@@ -185,3 +185,18 @@ test('curl -rc versions', async () => {
185185 labels : undefined
186186 } )
187187} )
188+
189+ test ( 'errors out if GitHub API returns 500' , async ( ) => {
190+ mockHTTPSGet . __RETURN__ = `<?xml version="1.0" encoding="UTF-8"?>
191+ <feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US">
192+ <entry>
193+ <title>Hello></title>
194+ <published>${ new Date ( ) . toUTCString ( ) } </published>
195+ <content type="html">TBD</content>
196+ </entry>
197+ </feed>`
198+ octokit . rest . issues . listForRepo . mockReturnValueOnce ( { status : 500 , data : [ ] , message : 'Server Error' } )
199+ // Expect an error to be thrown
200+ await expect ( run ( ) ) . rejects . toThrow ( 'Failed to list issues: 500 {"message":"Server Error"}' )
201+ expect ( octokit . rest . issues . listForRepo ) . toHaveBeenCalledTimes ( 1 )
202+ } )
0 commit comments