Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #28 from dotnetCarpenter/fix_offline_error
Browse files Browse the repository at this point in the history
Fix offline error
  • Loading branch information
Steve Peak authored Sep 1, 2016
2 parents 6f21a16 + fc1106b commit d9e5f5f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/codecov.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ var sendToCodecovV2 = function(codecov_endpoint, query, upload_body, on_success,
}, function(err, response, result){
if (err || response.statusCode !== 200) {
console.log(' ' + (err || response.body));
return on_failure(response.statusCode, response.body);
return response ? on_failure(response.statusCode, response.body) : on_failure(err.code, err.message);

} else {
console.log(' Success!');
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"execSync": "1.0.2"
},
"devDependencies": {
"expect.js": "0.3.1",
"istanbul": "0.4.4",
"jshint": "2.9.2",
"mocha": "2.5.3"
"expect.js": "^0.3.1",
"istanbul": "^0.4.5",
"jshint": "^2.9.3",
"mocha": "^3.0.2"
}
}
41 changes: 37 additions & 4 deletions test/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if (!execSync) {

describe("Codecov", function(){
it("can get upload to v2", function(done){
var self = this;
codecov.sendToCodecovV2('https://codecov.io',
{
token: 'f881216b-b5c0-4eb1-8f21-b51887d1d506',
Expand All @@ -22,12 +23,18 @@ describe("Codecov", function(){
expect(body).to.contain('http://codecov.io/github/codecov/ci-repo/commit/c739768fcac68144a3a6d82305b9c4106934d31a');
done();
},
function(err){
throw err;
function(errCode, errMsg){
if(errCode === 'EAI_AGAIN'){
self.skip(); // offline - we can not test upload
return;
}
throw new Error(errMsg);
});
});

it("can get upload to v3", function(done){
var self = this;
this.timeout(3000); // give this test extra time to run (default is 2000ms)
codecov.sendToCodecovV3('https://codecov.io',
{
token: 'f881216b-b5c0-4eb1-8f21-b51887d1d506',
Expand All @@ -39,9 +46,35 @@ describe("Codecov", function(){
expect(body).to.contain('http://codecov.io/github/codecov/ci-repo/commit/c739768fcac68144a3a6d82305b9c4106934d31a');
done();
},
function(err){
throw err;
function(errCode, errMsg){
if(errCode === 'EAI_AGAIN'){
self.skip(); // offline - we can not test upload
return;
}
throw new Error(errMsg);
});
});

it("upload v2 doesn't throw runtime error", function(done){
expect(codecov.sendToCodecovV2.bind(null,
'https://codecov.io',
{
token: 'f881216b-b5c0-4eb1-8f21-b51887d1d506',
commit: 'c739768fcac68144a3a6d82305b9c4106934d31a',
branch: 'master'
},
'testing node-'+codecov.version,
function(body){
expect(body).to.contain('http://codecov.io/github/codecov/ci-repo/commit/c739768fcac68144a3a6d82305b9c4106934d31a');
done();
},
function(errCode, errMsg){
if(errCode === 'EAI_AGAIN'){
done();
}
throw new Error(errMsg);
}
)).to.not.throwException();
})

});

0 comments on commit d9e5f5f

Please sign in to comment.