[CodeClimate] Added missing try-catch block (#1613)

* Added missing try-catch block

* Added tests to cover malformed responses
This commit is contained in:
Pyves
2018-04-01 16:32:43 +01:00
committed by Thaddée Tyl
parent c5884b1915
commit dd35739c5c
2 changed files with 55 additions and 27 deletions

View File

@@ -95,4 +95,27 @@ t.create('maintainability letter for repo without snapshots')
value: 'unknown'
});
t.create('malformed response for outer user repos query')
.get('/maintainability/angular/angular.js.json')
.intercept(nock => nock('https://api.codeclimate.com')
.get('/v1/repos?github_slug=angular/angular.js')
.reply(200, {
data: [{}] // No relationships in the list of data elements.
}))
.expectJSON({
name: 'maintainability',
value: 'invalid'
});
t.create('malformed response for inner specific repo query')
.get('/maintainability/angular/angular.js.json')
.intercept(nock => nock('https://api.codeclimate.com', {allowUnmocked: true})
.get('/v1/repos/526933117e00a40567008444/snapshots/5ab4427859c16c0001003cad')
.reply(200, {})) // No data.
.networkOn() // Combined with allowUnmocked: true, this allows the outer user repos query to go through.
.expectJSON({
name: 'maintainability',
value: 'invalid'
});
module.exports = t;