Skip to content

Commit

Permalink
Merge pull request #370 from felickz/fix-request-error-handling
Browse files Browse the repository at this point in the history
Fix Dependency Review API response error handling
  • Loading branch information
febuiles committed Jan 9, 2023
2 parents efd7880 + 6855e6e commit 42ee3c8
Show file tree
Hide file tree
Showing 6 changed files with 383 additions and 115 deletions.
29 changes: 29 additions & 0 deletions __tests__/dependency-graph.int.test.ts
@@ -0,0 +1,29 @@
import {RequestError} from '@octokit/request-error'
import * as dependencyGraph from '../src/dependency-graph'
import * as core from '@actions/core'

// mock call to core.getInput('repo-token'.. to avoid environment setup - Input required and not supplied: repo-token
jest.mock('@actions/core', () => ({
getInput: (input: string) => {
if (input === 'repo-token') {
return 'gh_testtoken'
}
}
}))

test('it properly catches RequestError type', async () => {
const token = core.getInput('repo-token', {required: true})
expect(token).toBe('gh_testtoken')

//Integration test to make an API request using current dependencies and ensure response can parse into RequestError
try {
await dependencyGraph.compare({
owner: 'actions',
repo: 'dependency-review-action',
baseRef: 'refs/heads/master',
headRef: 'refs/heads/master'
})
} catch (error) {
expect(error).toBeInstanceOf(RequestError)
}
})
254 changes: 168 additions & 86 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit 42ee3c8

Please sign in to comment.