diff --git a/service-tests/codecov.js b/service-tests/codecov.js index 7dc9ff9d7136c..e2ab77124e66a 100644 --- a/service-tests/codecov.js +++ b/service-tests/codecov.js @@ -2,7 +2,7 @@ const Joi = require('joi'); const ServiceTester = require('./runner/service-tester'); -const { isPercentage } = require('./helpers/validators'); +const { isIntegerPercentage } = require('./helpers/validators'); const t = new ServiceTester({ id: 'codecov', title: 'Codecov.io' }); module.exports = t; @@ -11,12 +11,12 @@ t.create('gets coverage status') .get('/c/github/codecov/example-python.json') .expectJSONTypes(Joi.object().keys({ name: 'coverage', - value: isPercentage + value: isIntegerPercentage, })); t.create('gets coverate status for branch') .get('/c/github/codecov/example-python/master.json') .expectJSONTypes(Joi.object().keys({ name: 'coverage', - value: isPercentage + value: isIntegerPercentage, })); diff --git a/service-tests/coveralls.js b/service-tests/coveralls.js index b32ee86781b70..17262a36b95cb 100644 --- a/service-tests/coveralls.js +++ b/service-tests/coveralls.js @@ -2,7 +2,7 @@ const Joi = require('joi'); const ServiceTester = require('./runner/service-tester'); -const { isPercentage } = require('./helpers/validators'); +const { isIntegerPercentage } = require('./helpers/validators'); const t = new ServiceTester({ id: 'coveralls', title: 'Coveralls.io' }); module.exports = t; @@ -92,12 +92,12 @@ t.create('show coverage for bitbucket with branch') t.create('github coverage') .get('/github/jekyll/jekyll.json') - .expectJSONTypes(Joi.object().keys({ name: 'coverage', value: isPercentage })); + .expectJSONTypes(Joi.object().keys({ name: 'coverage', value: isIntegerPercentage })); t.create('github coverage for legacy link') .get('/jekyll/jekyll.json') - .expectJSONTypes(Joi.object().keys({ name: 'coverage', value: isPercentage })); + .expectJSONTypes(Joi.object().keys({ name: 'coverage', value: isIntegerPercentage })); t.create('bitbucket coverage') .get('/bitbucket/pyKLIP/pyklip.json') - .expectJSONTypes(Joi.object().keys({ name: 'coverage', value: isPercentage })); + .expectJSONTypes(Joi.object().keys({ name: 'coverage', value: isIntegerPercentage })); diff --git a/service-tests/helpers/validators.js b/service-tests/helpers/validators.js index 4565b2683800a..0982cca75cc47 100644 --- a/service-tests/helpers/validators.js +++ b/service-tests/helpers/validators.js @@ -48,7 +48,8 @@ const isMetricOpenIssues = withRegex(/^[1-9][0-9]*[kMGTPEZY]? open$/); const isMetricOverTimePeriod = withRegex(/^[1-9][0-9]*[kMGTPEZY]?\/(year|month|4 weeks|week|day)$/); -const isPercentage = withRegex(/^[0-9]+%$/); +const isIntegerPercentage = withRegex(/^[0-9]+%$/); +const isDecimalPercentage = withRegex(/^[0-9]+\.[0-9]*%$/); const isFileSize = withRegex(/^[0-9]*[.]?[0-9]+\s(B|kB|MB|GB|TB|PB|EB|ZB|YB)$/); @@ -67,7 +68,8 @@ module.exports = { isMetric, isMetricOpenIssues, isMetricOverTimePeriod, - isPercentage, + isIntegerPercentage, + isDecimalPercentage, isFileSize, isFormattedDate }; diff --git a/service-tests/sonarqube.js b/service-tests/sonarqube.js index 75c32a041fde5..09f64fbdce244 100644 --- a/service-tests/sonarqube.js +++ b/service-tests/sonarqube.js @@ -3,7 +3,7 @@ const Joi = require('joi'); const ServiceTester = require('./runner/service-tester'); const { - isPercentage, + isIntegerPercentage, } = require('./helpers/validators'); const t = new ServiceTester({ id: 'sonar', title: 'SonarQube' }); @@ -13,28 +13,28 @@ t.create('Tech Debt') .get('/http/sonar.petalslink.com/org.ow2.petals%3Apetals-se-ase/tech_debt.json') .expectJSONTypes(Joi.object().keys({ name: 'tech debt', - value: isPercentage + value: isIntegerPercentage })); t.create('Coverage') .get('/http/sonar.petalslink.com/org.ow2.petals%3Apetals-se-ase/coverage.json') .expectJSONTypes(Joi.object().keys({ name: 'coverage', - value: isPercentage + value: isIntegerPercentage })); t.create('Tech Debt (legacy API supported)') .get('/4.2/http/sonar.petalslink.com/org.ow2.petals%3Apetals-se-ase/tech_debt.json') .expectJSONTypes(Joi.object().keys({ name: 'tech debt', - value: isPercentage + value: isIntegerPercentage })); t.create('Coverage (legacy API supported)') .get('/4.2/http/sonar.petalslink.com/org.ow2.petals%3Apetals-se-ase/coverage.json') .expectJSONTypes(Joi.object().keys({ name: 'coverage', - value: isPercentage + value: isIntegerPercentage })); t.create('Tech Debt (legacy API unsupported)') diff --git a/service-tests/uptimerobot.js b/service-tests/uptimerobot.js index 1fc272d031e91..8b944ec3616ce 100644 --- a/service-tests/uptimerobot.js +++ b/service-tests/uptimerobot.js @@ -4,7 +4,7 @@ const Joi = require('joi'); const ServiceTester = require('./runner/service-tester'); const isUptimeStatus = Joi.string().regex(/^(paused|not checked yet|up|seems down|down)$/); -const { isPercentage } = require('./helpers/validators'); +const { isDecimalPercentage } = require('./helpers/validators'); const t = new ServiceTester({ id: 'uptimerobot', title: 'Uptime Robot' }); module.exports = t; @@ -66,14 +66,14 @@ t.create('Uptime Robot: Percentage (valid)') .get('/ratio/m778918918-3e92c097147760ee39d02d36.json') .expectJSONTypes(Joi.object().keys({ name: 'uptime', - value: isPercentage, + value: isDecimalPercentage, })); t.create('Uptime Robot: Percentage (valid, with numberOfDays param)') .get('/ratio/7/m778918918-3e92c097147760ee39d02d36.json') .expectJSONTypes(Joi.object().keys({ name: 'uptime', - value: isPercentage, + value: isDecimalPercentage, })); t.create('Uptime Robot: Percentage (invalid, correct format)')