Skip to content

Commit

Permalink
Using invalidJSON instead of other ways to mock an invalid JSON (badg…
Browse files Browse the repository at this point in the history
  • Loading branch information
platan authored Jul 11, 2018
1 parent 6f54c16 commit 9ca7474
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions services/cocoapods/cocoapods.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Joi = require('joi');
const ServiceTester = require('../service-tester');

const { invalidJSON } = require('../response-fixtures');
const {
isIntegerPercentage,
isVPlusDottedVersionAtLeastOne,
Expand Down Expand Up @@ -45,7 +45,7 @@ t.create('version (unexpected response)')
.get('/v/AFNetworking.json')
.intercept(nock => nock('https://trunk.cocoapods.org')
.get('/api/v1/pods/AFNetworking/specs/latest')
.reply(200, "{{{{{invalid json}}")
.reply(invalidJSON)
)
.expectJSON({name: 'pod', value: 'invalid'});

Expand All @@ -72,7 +72,7 @@ t.create('platform (unexpected response)')
.get('/p/AFNetworking.json')
.intercept(nock => nock('https://trunk.cocoapods.org')
.get('/api/v1/pods/AFNetworking/specs/latest')
.reply(200, "{{{{{invalid json}}")
.reply(invalidJSON)
)
.expectJSON({name: 'platform', value: 'invalid'});

Expand All @@ -96,7 +96,7 @@ t.create('license (unexpected response)')
.get('/l/AFNetworking.json')
.intercept(nock => nock('https://trunk.cocoapods.org')
.get('/api/v1/pods/AFNetworking/specs/latest')
.reply(200, "{{{{{invalid json}}")
.reply(invalidJSON)
)
.expectJSON({name: 'license', value: 'invalid'});

Expand Down Expand Up @@ -131,7 +131,7 @@ t.create('doc percent (unexpected response)')
.get('/metrics/doc-percent/AFNetworking.json')
.intercept(nock => nock('https://metrics.cocoapods.org')
.get('/api/v1/pods/AFNetworking')
.reply(200, "{{{{{invalid json}}")
.reply(invalidJSON)
)
.expectJSON({name: 'docs', value: 'invalid'});

Expand Down Expand Up @@ -172,7 +172,7 @@ t.create('downloads (unexpected response)')
.get('/dt/AFNetworking.json')
.intercept(nock => nock('https://metrics.cocoapods.org')
.get('/api/v1/pods/AFNetworking')
.reply(200, "{{{{{invalid json}}")
.reply(invalidJSON)
)
.expectJSON({name: 'downloads', value: 'invalid'});

Expand Down Expand Up @@ -206,6 +206,6 @@ t.create('apps (unexpected response)')
.get('/at/AFNetworking.json')
.intercept(nock => nock('https://metrics.cocoapods.org')
.get('/api/v1/pods/AFNetworking')
.reply(200, "{{{{{invalid json}}")
.reply(invalidJSON)
)
.expectJSON({name: 'apps', value: 'invalid'});
4 changes: 2 additions & 2 deletions services/david/david.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Joi = require('joi');
const ServiceTester = require('../service-tester');

const { invalidJSON } = require('../response-fixtures');
const isDependencyStatus = Joi.string().valid('insecure', 'up to date', 'out of date');

const t = new ServiceTester({ id: 'david', title: 'David' });
Expand Down Expand Up @@ -65,6 +65,6 @@ t.create('david dependencies (unexpected response)')
.get('/expressjs/express.json')
.intercept(nock => nock('https://david-dm.org')
.get('/expressjs/express/info.json')
.reply(200, "{{{{{invalid json}}")
.reply(invalidJSON)
)
.expectJSON({name: 'dependencies', value: 'invalid'});
6 changes: 3 additions & 3 deletions services/lgtm/lgtm.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Joi = require('joi');
const ServiceTester = require('../service-tester');

const { invalidJSON } = require('../response-fixtures');
const t = new ServiceTester({ id: 'lgtm', title: 'LGTM' })
module.exports = t;

Expand Down Expand Up @@ -54,7 +54,7 @@ t.create('alerts: invalid json')
.get('/alerts/g/apache/cloudstack.json')
.intercept(nock => nock('https://lgtm.com')
.get('/api/v0.1/project/g/apache/cloudstack/details')
.reply(200, 'not a json string'))
.reply(invalidJSON))
.expectJSON({ name: 'lgtm', value: 'invalid' });

t.create('alerts: lgtm inaccessible')
Expand All @@ -80,7 +80,7 @@ t.create('grade: invalid json')
.get('/grade/java/g/apache/cloudstack.json')
.intercept(nock => nock('https://lgtm.com')
.get('/api/v0.1/project/g/apache/cloudstack/details')
.reply(200, 'not a json string'))
.reply(invalidJSON))
.expectJSON({ name: 'code quality: java', value: 'invalid' });

t.create('grade: json missing languages')
Expand Down

0 comments on commit 9ca7474

Please sign in to comment.