Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UptimeRobot] Test with regex that accepts decimals #1448

Merged
merged 1 commit into from
Jan 15, 2018
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
6 changes: 3 additions & 3 deletions service-tests/codecov.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
}));
8 changes: 4 additions & 4 deletions service-tests/coveralls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 }));
6 changes: 4 additions & 2 deletions service-tests/helpers/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)$/);

Expand All @@ -67,7 +68,8 @@ module.exports = {
isMetric,
isMetricOpenIssues,
isMetricOverTimePeriod,
isPercentage,
isIntegerPercentage,
isDecimalPercentage,
isFileSize,
isFormattedDate
};
10 changes: 5 additions & 5 deletions service-tests/sonarqube.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand All @@ -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)')
Expand Down
6 changes: 3 additions & 3 deletions service-tests/uptimerobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)')
Expand Down