Skip to content

Commit

Permalink
Removing some unnecessary invalid key error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion committed Jun 26, 2019
1 parent 33d6f9d commit 8425083
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
6 changes: 0 additions & 6 deletions lib/swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ exports.run = function({ args, opts }) {

function error(err) {
try {
if (err.statusCode === 401) {
return Promise.reject(
new Error('There was a problem with your api key. Please try again.'),
);
}

return Promise.reject(new Error(JSON.parse(err.error).description));
} catch (e) {
return Promise.reject(new Error('There was an error uploading!'));
Expand Down
14 changes: 0 additions & 14 deletions test/swagger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ describe('swagger command', () => {
'No api key provided. Please use --key',
));

it('should error if a bad api key is provided', async () => {
const badKey = 'thisIsABadApiKey';
const mock = nock(config.host)
.post('/api/v1/swagger', body => body.match('form-data; name="swagger"'))
.basicAuth({ user: badKey })
.reply(401);

await expect(swagger(['./test/fixtures/swagger.json'], { key: badKey })).rejects.toThrow(
'There was a problem with your api key. Please try again.',
);

mock.done();
});

it('should error if no file was provided or able to be discovered', () => {
expect(swagger([], { key })).rejects.toThrow(
"We couldn't find a Swagger or OpenAPI file.\n\n" +
Expand Down

0 comments on commit 8425083

Please sign in to comment.