Skip to content

Commit 42ee3c8

Browse files
author
Federico Builes
authored
Merge pull request #370 from felickz/fix-request-error-handling
Fix Dependency Review API response error handling
2 parents efd7880 + 6855e6e commit 42ee3c8

File tree

6 files changed

+383
-115
lines changed

6 files changed

+383
-115
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {RequestError} from '@octokit/request-error'
2+
import * as dependencyGraph from '../src/dependency-graph'
3+
import * as core from '@actions/core'
4+
5+
// mock call to core.getInput('repo-token'.. to avoid environment setup - Input required and not supplied: repo-token
6+
jest.mock('@actions/core', () => ({
7+
getInput: (input: string) => {
8+
if (input === 'repo-token') {
9+
return 'gh_testtoken'
10+
}
11+
}
12+
}))
13+
14+
test('it properly catches RequestError type', async () => {
15+
const token = core.getInput('repo-token', {required: true})
16+
expect(token).toBe('gh_testtoken')
17+
18+
//Integration test to make an API request using current dependencies and ensure response can parse into RequestError
19+
try {
20+
await dependencyGraph.compare({
21+
owner: 'actions',
22+
repo: 'dependency-review-action',
23+
baseRef: 'refs/heads/master',
24+
headRef: 'refs/heads/master'
25+
})
26+
} catch (error) {
27+
expect(error).toBeInstanceOf(RequestError)
28+
}
29+
})

dist/index.js

Lines changed: 168 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)