forked from googleapis/release-please
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #7 from stainless-api/sam/sta-2052-trigger-release…
…-please-endpoint-fails-due-to-404-returned-by Check structure of octokit errors instead of via prototype instance
- Loading branch information
Showing
4 changed files
with
132 additions
and
10 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
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
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
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,69 @@ | ||
import {expect} from 'chai'; | ||
import {GraphqlResponseError} from '@octokit/graphql'; | ||
import { | ||
isOctokitGraphqlResponseError, | ||
isOctokitRequestError, | ||
} from '../../src/errors'; | ||
import {RequestError} from '@octokit/request-error'; | ||
|
||
describe('Errors', () => { | ||
describe('isOctokitRequestError', () => { | ||
it('should return true for valid RequestError', () => { | ||
const error = new RequestError('Not Found', 404, { | ||
request: {method: 'GET', url: '/foo/bar', headers: {}}, | ||
headers: {}, | ||
}); | ||
expect(isOctokitRequestError(error)).to.be.true; | ||
}); | ||
|
||
it('should return false for invalid RequestError', () => { | ||
const error = { | ||
name: 'SomeOtherError', | ||
status: 500, | ||
request: 'invalid_request_object', | ||
}; | ||
expect(isOctokitRequestError(error)).to.be.false; | ||
}); | ||
}); | ||
|
||
describe('isOctokitGraphqlResponseError', () => { | ||
it('should return true for valid GraphqlResponseError', () => { | ||
const error = new GraphqlResponseError( | ||
{ | ||
method: 'GET', | ||
url: '/foo/bar', | ||
}, | ||
{}, | ||
{ | ||
data: {}, | ||
errors: [ | ||
{ | ||
type: 'FORBIDDEN', | ||
message: 'Resource not accessible by integration', | ||
path: ['foo'], | ||
extensions: {}, | ||
locations: [ | ||
{ | ||
line: 123, | ||
column: 456, | ||
}, | ||
], | ||
}, | ||
], | ||
} | ||
); | ||
expect(isOctokitGraphqlResponseError(error)).to.be.true; | ||
}); | ||
|
||
it('should return false for invalid GraphqlResponseError', () => { | ||
const error = { | ||
request: {}, | ||
headers: {}, | ||
response: {}, | ||
name: 'SomeOtherError', | ||
errors: [], | ||
}; | ||
expect(isOctokitGraphqlResponseError(error)).to.be.false; | ||
}); | ||
}); | ||
}); |