-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #370 from felickz/fix-request-error-handling
Fix Dependency Review API response error handling
- Loading branch information
Showing
6 changed files
with
383 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.