[CircleCI] Extended existing try-catch block (#1614)

This commit is contained in:
Pyves
2018-03-30 09:34:20 +01:00
committed by GitHub
parent ac7c418222
commit 66c5d914c7
2 changed files with 15 additions and 8 deletions
+6 -7
View File
@@ -5915,17 +5915,16 @@ cache(function(data, match, sendBadge, request) {
var badgeData = getBadgeData('build', data);
request(apiUrl, {json:true}, function(err, res, data) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
if (data.message !== undefined){
badgeData.text[1] = data.message;
if (checkErrorResponse(badgeData, err, res, 'project not found')) {
sendBadge(format, badgeData);
return;
}
try {
if (data.message !== undefined){
badgeData.text[1] = data.message;
sendBadge(format, badgeData);
return;
}
var status = data[0].status;
switch(status) {
case 'success':
+9 -1
View File
@@ -25,7 +25,7 @@ t.create('circle ci (valid, with branch)')
t.create('circle ci (not found)')
.get('/project/github/PyvesB/EmptyRepo.json')
.expectJSON({name: 'build', value: 'Project not found'});
.expectJSON({name: 'build', value: 'project not found'});
t.create('circle ci (connection error)')
.get('/project/github/RedSparr0w/node-csgo-parser.json')
@@ -39,3 +39,11 @@ t.create('circle ci (unexpected response)')
.reply(invalidJSON)
)
.expectJSON({name: 'build', value: 'invalid'});
t.create('circle ci (no response data)')
.get('/project/github/RedSparr0w/node-csgo-parser.json')
.intercept(nock => nock('https://circleci.com')
.get('/api/v1.1/project/github/RedSparr0w/node-csgo-parser?filter=completed&limit=1')
.reply(200)
)
.expectJSON({ name: 'build', value: 'invalid' });