Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

api v2 #14

Merged
merged 5 commits into from
May 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

var optionsValidation = Joi.object({
endpoint: Joi.string().min(1).optional().example('https://codacy.com/coverage/:token/:commitId')
endpoint: Joi.string().min(1).optional().example('https://codacy.com/api/2.0/coverage/:commitId/:language')
});
var tokenValidation = Joi.string().required().min(1).example('1234567890');//TODO: Revisit this validation to see if we can better validate the values
var commitIdValidation = Joi.string().required().min(1).example('1234567890'); //TODO: Revisit this validation to see if we can better validate the values
Expand All @@ -26,7 +26,7 @@
throw optionsValid.error;
}

var endpoint = options.endpoint || 'https://www.codacy.com/api/coverage/:token/:commitId';
var endpoint = options.endpoint || 'https://www.codacy.com/api/2.0/coverage/:commitId/javascript';
logger.debug('Setting up reporter communicating to: ' + endpoint);

return {
Expand All @@ -45,13 +45,18 @@
return reject(validationErr);
}

var url = endpoint.replace(':token', token).replace(':commitId', commitId);
var url = endpoint.replace(':commitId', commitId);
logger.trace(util.format('Sending POST to %s', url));

return request({
url: url,
method: 'POST',
json: data,
headers: {
// jscs:disable
'project_token': token
// jscs:enable
},
resolveWithFullResponse: true
}).then(function (res) {
if (res.statusCode !== 200) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codacy-coverage",
"version": "1.1.1",
"version": "1.1.2",
"description": "Code Coverage reporter for Codacy.com",
"keywords": [
"codacy",
Expand Down
2 changes: 1 addition & 1 deletion test/handleInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
return helper.setupMockEndpoint('1234', '4321', bodyValidator)
.then(function () {
return expect(request({
url: 'https://www.codacy.com/api/coverage/1234/4321',
url: 'https://www.codacy.com/api/2.0/coverage/4321/javascript',
method: 'POST',
json: sampleCoverageData,
resolveWithFullResponse: true
Expand Down
2 changes: 1 addition & 1 deletion test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
expect(bodyValidator).to.be.ok();

return resolve(nock('https://www.codacy.com')
.post('/api/coverage/' + token + '/' + commitId, function (body) {
.post('/api/2.0/coverage/' + commitId + '/javascript', function (body) {
var result = bodyValidator.validate(body);
return result.error ? false : true;
})
Expand Down
2 changes: 1 addition & 1 deletion test/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
return helper.setupMockEndpoint('1234', '4321', bodyValidator)
.then(function () {
return expect(request({
url: 'https://www.codacy.com/api/coverage/1234/4321',
url: 'https://www.codacy.com/api/2.0/coverage/4321/javascript',
method: 'POST',
json: sampleCoverageData,
resolveWithFullResponse: true
Expand Down