Migrated most service tests to use new expectBadge (#3122)

This commit is contained in:
Pierre-Yves B
2019-02-28 21:43:23 +00:00
committed by GitHub
parent 4e2d144f97
commit 1f29c22d3d
230 changed files with 3480 additions and 4439 deletions

View File

@@ -1,22 +1,17 @@
'use strict'
const Joi = require('joi')
const { ServiceTester } = require('../tester')
const { isMetricOverTimePeriod } = require('../test-validators')
const t = (module.exports = new ServiceTester({ id: 'amo', title: 'AMO' }))
t.create('Weekly Downloads')
.get('/dw/IndieGala-Helper.json')
.expectJSONTypes(
Joi.object().keys({ name: 'downloads', value: isMetricOverTimePeriod })
)
.expectBadge({ label: 'downloads', message: isMetricOverTimePeriod })
t.create('Weekly Downloads (not found)')
.get('/dw/not-a-real-plugin.json')
.expectJSON({ name: 'downloads', value: 'not found' })
.expectBadge({ label: 'downloads', message: 'not found' })
t.create('/d URL should redirect to /dw')
.get('/d/IndieGala-Helper.json')
.expectJSONTypes(
Joi.object().keys({ name: 'downloads', value: isMetricOverTimePeriod })
)
.expectBadge({ label: 'downloads', message: isMetricOverTimePeriod })

View File

@@ -6,17 +6,15 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('Rating')
.get('/rating/IndieGala-Helper.json')
.expectJSONTypes(
Joi.object().keys({
name: 'rating',
value: Joi.string().regex(/^\d\/\d$/),
})
)
.expectBadge({
label: 'rating',
message: Joi.string().regex(/^\d\/\d$/),
})
t.create('Stars')
.get('/stars/IndieGala-Helper.json')
.expectJSONTypes(Joi.object().keys({ name: 'stars', value: isStarRating }))
.expectBadge({ label: 'stars', message: isStarRating })
t.create('Rating (not found)')
.get('/rating/not-a-real-plugin.json')
.expectJSON({ name: 'mozilla add-on', value: 'not found' })
.expectBadge({ label: 'mozilla add-on', message: 'not found' })

View File

@@ -1,13 +1,12 @@
'use strict'
const Joi = require('joi')
const { isMetric } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('Users')
.get('/IndieGala-Helper.json')
.expectJSONTypes(Joi.object().keys({ name: 'users', value: isMetric }))
.expectBadge({ label: 'users', message: isMetric })
t.create('Users (not found)')
.get('/not-a-real-plugin.json')
.expectJSON({ name: 'users', value: 'not found' })
.expectBadge({ label: 'users', message: 'not found' })

View File

@@ -1,18 +1,15 @@
'use strict'
const Joi = require('joi')
const { isVPlusDottedVersionAtLeastOne } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('Version')
.get('/IndieGala-Helper.json')
.expectJSONTypes(
Joi.object().keys({
name: 'mozilla add-on',
value: isVPlusDottedVersionAtLeastOne,
})
)
.expectBadge({
label: 'mozilla add-on',
message: isVPlusDottedVersionAtLeastOne,
})
t.create('Version (not found)')
.get('/not-a-real-plugin.json')
.expectJSON({ name: 'mozilla add-on', value: 'not found' })
.expectBadge({ label: 'mozilla add-on', message: 'not found' })

View File

@@ -1,15 +1,12 @@
'use strict'
const Joi = require('joi')
const { nonNegativeInteger } = require('../validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('quality score (valid)')
.get('/432.json')
.expectJSONTypes(
Joi.object().keys({ name: 'quality', value: nonNegativeInteger })
)
.expectBadge({ label: 'quality', message: nonNegativeInteger })
t.create('quality score (not found)')
.get('/0101.json')
.expectJSON({ name: 'quality', value: 'no score available' })
.expectBadge({ label: 'quality', message: 'no score available' })

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { ServiceTester } = require('../tester')
const { isMetric } = require('../test-validators')
@@ -12,18 +11,16 @@ const t = (module.exports = new ServiceTester({
t.create('role name (valid)')
.get('/14542.json')
.expectJSON({ name: 'role', value: 'openwisp.openwisp2' })
.expectBadge({ label: 'role', message: 'openwisp.openwisp2' })
t.create('role name (not found)')
.get('/000.json')
.expectJSON({ name: 'role', value: 'not found' })
.expectBadge({ label: 'role', message: 'not found' })
t.create('role downloads (valid)')
.get('/d/14542.json')
.expectJSONTypes(
Joi.object().keys({ name: 'role downloads', value: isMetric })
)
.expectBadge({ label: 'role downloads', message: isMetric })
t.create('role downloads (not found)')
.get('/d/does-not-exist.json')
.expectJSON({ name: 'role downloads', value: 'not found' })
.expectBadge({ label: 'role downloads', message: 'not found' })

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { ServiceTester } = require('../tester')
const { invalidJSON } = require('../response-fixtures')
const { isMetric, isVPlusTripleDottedVersion } = require('../test-validators')
@@ -12,29 +11,27 @@ const t = (module.exports = new ServiceTester({
t.create('Downloads')
.get('/dm/vim-mode.json')
.expectJSONTypes(Joi.object().keys({ name: 'downloads', value: isMetric }))
.expectBadge({ label: 'downloads', message: isMetric })
t.create('Version')
.get('/v/vim-mode.json')
.expectJSONTypes(
Joi.object().keys({ name: 'apm', value: isVPlusTripleDottedVersion })
)
.expectBadge({ label: 'apm', message: isVPlusTripleDottedVersion })
t.create('License')
.get('/l/vim-mode.json')
.expectJSON({ name: 'license', value: 'MIT' })
.expectBadge({ label: 'license', message: 'MIT' })
t.create('Downloads | Package not found')
.get('/dm/notapackage.json')
.expectJSON({ name: 'downloads', value: 'package not found' })
.expectBadge({ label: 'downloads', message: 'package not found' })
t.create('Version | Package not found')
.get('/v/notapackage.json')
.expectJSON({ name: 'apm', value: 'package not found' })
.expectBadge({ label: 'apm', message: 'package not found' })
t.create('License | Package not found')
.get('/l/notapackage.json')
.expectJSON({ name: 'license', value: 'package not found' })
.expectBadge({ label: 'license', message: 'package not found' })
t.create('Invalid version')
.get('/dm/vim-mode.json')
@@ -43,7 +40,7 @@ t.create('Invalid version')
.get('/api/packages/vim-mode')
.reply([200, '{"releases":{}}'])
)
.expectJSON({ name: 'downloads', value: 'unparseable json response' })
.expectBadge({ label: 'downloads', message: 'unparseable json response' })
t.create('Invalid License')
.get('/l/vim-mode.json')
@@ -52,7 +49,7 @@ t.create('Invalid License')
.get('/api/packages/vim-mode')
.reply([200, '{"metadata":{}}'])
)
.expectJSON({ name: 'license', value: 'unparseable json response' })
.expectBadge({ label: 'license', message: 'unparseable json response' })
t.create('Unexpected response')
.get('/dm/vim-mode.json')
@@ -61,4 +58,4 @@ t.create('Unexpected response')
.get('/api/packages/vim-mode')
.reply(invalidJSON)
)
.expectJSON({ name: 'downloads', value: 'unparseable json response' })
.expectBadge({ label: 'downloads', message: 'unparseable json response' })

View File

@@ -1,23 +1,25 @@
'use strict'
const Joi = require('joi')
const { isBuildStatus } = require('../build-status')
const t = (module.exports = require('../tester').createServiceTester())
t.create('CI status')
.timeout(10000)
.get('/gruntjs/grunt.json')
.expectJSONTypes(Joi.object().keys({ name: 'build', value: isBuildStatus }))
.expectBadge({ label: 'build', message: isBuildStatus })
t.create('CI status on branch')
.timeout(10000)
.get('/gruntjs/grunt/master.json')
.expectJSONTypes(Joi.object().keys({ name: 'build', value: isBuildStatus }))
.expectBadge({ label: 'build', message: isBuildStatus })
t.create('CI status on nonexistent project')
.timeout(10000)
.get('/somerandomproject/thatdoesntexist.json')
.expectJSON({ name: 'build', value: 'project not found or access denied' })
.expectBadge({
label: 'build',
message: 'project not found or access denied',
})
t.create('CI status on project that does exist but has no builds yet')
.get('/gruntjs/grunt.json?style=_shields_test')
@@ -26,4 +28,8 @@ t.create('CI status on project that does exist but has no builds yet')
.get('/gruntjs/grunt')
.reply(200, {})
)
.expectJSON({ name: 'build', value: 'no builds found', color: 'lightgrey' })
.expectBadge({
label: 'build',
message: 'no builds found',
color: 'lightgrey',
})

View File

@@ -23,23 +23,17 @@ const isCompactCustomAppveyorTestTotals = Joi.string().regex(
t.create('Test status')
.timeout(10000)
.get('/NZSmartie/coap-net-iu0to.json')
.expectJSONTypes(
Joi.object().keys({ name: 'tests', value: isAppveyorTestTotals })
)
.expectBadge({ label: 'tests', message: isAppveyorTestTotals })
t.create('Test status on branch')
.timeout(10000)
.get('/NZSmartie/coap-net-iu0to/master.json')
.expectJSONTypes(
Joi.object().keys({ name: 'tests', value: isAppveyorTestTotals })
)
.expectBadge({ label: 'tests', message: isAppveyorTestTotals })
t.create('Test status with compact message')
.timeout(10000)
.get('/NZSmartie/coap-net-iu0to.json?compact_message')
.expectJSONTypes(
Joi.object().keys({ name: 'tests', value: isCompactAppveyorTestTotals })
)
.expectBadge({ label: 'tests', message: isCompactAppveyorTestTotals })
t.create('Test status with custom labels')
.timeout(10000)
@@ -50,9 +44,7 @@ t.create('Test status with custom labels')
skipped_label: 'n/a',
},
})
.expectJSONTypes(
Joi.object().keys({ name: 'tests', value: isCustomAppveyorTestTotals })
)
.expectBadge({ label: 'tests', message: isCustomAppveyorTestTotals })
t.create('Test status with compact message and custom labels')
.timeout(10000)
@@ -64,17 +56,18 @@ t.create('Test status with compact message and custom labels')
skipped_label: '🤷',
})}`
)
.expectJSONTypes(
Joi.object().keys({
name: 'tests',
value: isCompactCustomAppveyorTestTotals,
})
)
.expectBadge({
label: 'tests',
message: isCompactCustomAppveyorTestTotals,
})
t.create('Test status on non-existent project')
.timeout(10000)
.get('/somerandomproject/thatdoesntexist.json')
.expectJSON({ name: 'tests', value: 'project not found or access denied' })
.expectBadge({
label: 'tests',
message: 'project not found or access denied',
})
t.create('Test status on project that does exist but has no builds yet')
.get('/gruntjs/grunt.json?style=_shields_test')
@@ -83,4 +76,8 @@ t.create('Test status on project that does exist but has no builds yet')
.get('/gruntjs/grunt')
.reply(200, {})
)
.expectJSON({ name: 'tests', value: 'no builds found', color: 'lightgrey' })
.expectBadge({
label: 'tests',
message: 'no builds found',
color: 'lightgrey',
})

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { ServiceTester } = require('../tester')
const {
isVPlusDottedVersionNClausesWithOptionalSuffix,
@@ -16,49 +15,43 @@ const t = (module.exports = new ServiceTester({
t.create('version (valid)')
.get('/version/yaourt.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'aur',
value: isVPlusDottedVersionNClausesWithOptionalSuffix,
color: 'blue',
})
)
.expectBadge({
label: 'aur',
message: isVPlusDottedVersionNClausesWithOptionalSuffix,
color: 'blue',
})
t.create('version (valid, out of date)')
.get('/version/gog-gemini-rue.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'aur',
value: isVPlusDottedVersionNClausesWithOptionalSuffix,
color: 'orange',
})
)
.expectBadge({
label: 'aur',
message: isVPlusDottedVersionNClausesWithOptionalSuffix,
color: 'orange',
})
t.create('version (not found)')
.get('/version/not-a-package.json')
.expectJSON({ name: 'aur', value: 'package not found' })
.expectBadge({ label: 'aur', message: 'package not found' })
// votes tests
t.create('votes (valid)')
.get('/votes/yaourt.json')
.expectJSONTypes(
Joi.object().keys({
name: 'votes',
value: isMetric,
})
)
.expectBadge({
label: 'votes',
message: isMetric,
})
t.create('votes (not found)')
.get('/votes/not-a-package.json')
.expectJSON({ name: 'votes', value: 'package not found' })
.expectBadge({ label: 'votes', message: 'package not found' })
// license tests
t.create('license (valid)')
.get('/license/yaourt.json')
.expectJSON({ name: 'license', value: 'GPL' })
.expectBadge({ label: 'license', message: 'GPL' })
t.create('license (not found)')
.get('/license/not-a-package.json')
.expectJSON({ name: 'license', value: 'package not found' })
.expectBadge({ label: 'license', message: 'package not found' })

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { isBuildStatus } = require('../build-status')
const t = (module.exports = require('../tester').createServiceTester())
@@ -9,37 +8,33 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('default branch')
.get('/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: isBuildStatus,
})
)
.expectBadge({
label: 'build',
message: isBuildStatus,
})
t.create('named branch')
.get('/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2/master.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: isBuildStatus,
})
)
.expectBadge({
label: 'build',
message: isBuildStatus,
})
t.create('unknown definition')
.get('/larsbrinkhoff/953a34b9-5966-4923-a48a-c41874cfb5f5/515.json')
.expectJSON({ name: 'build', value: 'definition not found' })
.expectBadge({ label: 'build', message: 'definition not found' })
t.create('unknown project')
.get('/larsbrinkhoff/foo/515.json')
.expectJSON({ name: 'build', value: 'user or project not found' })
.expectBadge({ label: 'build', message: 'user or project not found' })
t.create('unknown user')
.get('/notarealuser/foo/515.json')
.expectJSON({ name: 'build', value: 'user or project not found' })
.expectBadge({ label: 'build', message: 'user or project not found' })
// The following build definition has always a partially succeeded status
t.create('partially succeeded build')
.get(
'/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/4.json?style=_shields_test'
)
.expectJSON({ name: 'build', value: 'passing', color: 'orange' })
.expectBadge({ label: 'build', message: 'passing', color: 'orange' })

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { isIntegerPercentage } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
@@ -56,25 +55,21 @@ const expCoverageMultipleReports = '77%'
t.create('default branch coverage')
.get(`${uriPrefix}/${linuxDefinitionId}.json`)
.expectJSONTypes(
Joi.object().keys({
name: 'coverage',
value: isIntegerPercentage,
})
)
.expectBadge({
label: 'coverage',
message: isIntegerPercentage,
})
t.create('named branch without ref')
.get(`${uriPrefix}/${windowsDefinitionId}/init.json`)
.expectJSONTypes(
Joi.object().keys({
name: 'coverage',
value: isIntegerPercentage,
})
)
.expectBadge({
label: 'coverage',
message: isIntegerPercentage,
})
t.create('unknown build definition')
.get(`${uriPrefix}/${nonExistentDefinitionId}.json`)
.expectJSON({ name: 'coverage', value: 'build pipeline not found' })
.expectBadge({ label: 'coverage', message: 'build pipeline not found' })
t.create('404 latest build error response')
.get(mockBadgeUriPath)
@@ -83,9 +78,9 @@ t.create('404 latest build error response')
.get(mockLatestBuildApiUriPath)
.reply(404)
)
.expectJSON({
name: 'coverage',
value: 'build pipeline or coverage not found',
.expectBadge({
label: 'coverage',
message: 'build pipeline or coverage not found',
})
t.create('no build response')
@@ -100,7 +95,7 @@ t.create('no build response')
value: [],
})
)
.expectJSON({ name: 'coverage', value: 'build pipeline not found' })
.expectBadge({ label: 'coverage', message: 'build pipeline not found' })
t.create('404 code coverage error response')
.get(mockBadgeUriPath)
@@ -111,9 +106,9 @@ t.create('404 code coverage error response')
.get(mockCodeCoverageApiUriPath)
.reply(404)
)
.expectJSON({
name: 'coverage',
value: 'build pipeline or coverage not found',
.expectBadge({
label: 'coverage',
message: 'build pipeline or coverage not found',
})
t.create('invalid code coverage response')
@@ -125,7 +120,7 @@ t.create('invalid code coverage response')
.get(mockCodeCoverageApiUriPath)
.reply(200, {})
)
.expectJSON({ name: 'coverage', value: 'invalid response data' })
.expectBadge({ label: 'coverage', message: 'invalid response data' })
t.create('no code coverage reports')
.get(mockBadgeUriPath)
@@ -136,7 +131,7 @@ t.create('no code coverage reports')
.get(mockCodeCoverageApiUriPath)
.reply(200, { coverageData: [] })
)
.expectJSON({ name: 'coverage', value: '0%' })
.expectBadge({ label: 'coverage', message: '0%' })
t.create('no code coverage reports')
.get(mockBadgeUriPath)
@@ -147,7 +142,7 @@ t.create('no code coverage reports')
.get(mockCodeCoverageApiUriPath)
.reply(200, { coverageData: [] })
)
.expectJSON({ name: 'coverage', value: '0%' })
.expectBadge({ label: 'coverage', message: '0%' })
t.create('no line coverage stats')
.get(mockBadgeUriPath)
@@ -164,7 +159,7 @@ t.create('no line coverage stats')
],
})
)
.expectJSON({ name: 'coverage', value: '0%' })
.expectBadge({ label: 'coverage', message: '0%' })
t.create('single line coverage stats')
.get(mockBadgeUriPath)
@@ -181,7 +176,7 @@ t.create('single line coverage stats')
],
})
)
.expectJSON({ name: 'coverage', value: expCoverageSingleReport })
.expectBadge({ label: 'coverage', message: expCoverageSingleReport })
t.create('mixed line and branch coverage stats')
.get(mockBadgeUriPath)
@@ -198,7 +193,7 @@ t.create('mixed line and branch coverage stats')
],
})
)
.expectJSON({ name: 'coverage', value: expCoverageSingleReport })
.expectBadge({ label: 'coverage', message: expCoverageSingleReport })
t.create('multiple line coverage stat reports')
.get(mockBadgeUriPath)
@@ -235,7 +230,7 @@ t.create('single JaCoCo style line coverage stats')
],
})
)
.expectJSON({ name: 'coverage', value: expCoverageSingleReport })
.expectBadge({ label: 'coverage', message: expCoverageSingleReport })
t.create('mixed JaCoCo style line and branch coverage stats')
.get(mockBadgeUriPath)
@@ -252,7 +247,7 @@ t.create('mixed JaCoCo style line and branch coverage stats')
],
})
)
.expectJSON({ name: 'coverage', value: expCoverageSingleReport })
.expectBadge({ label: 'coverage', message: expCoverageSingleReport })
t.create('multiple JaCoCo style line coverage stat reports')
.get(mockBadgeUriPath)
@@ -269,4 +264,4 @@ t.create('multiple JaCoCo style line coverage stat reports')
],
})
)
.expectJSON({ name: 'coverage', value: expCoverageMultipleReports })
.expectBadge({ label: 'coverage', message: expCoverageMultipleReports })

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { isBuildStatus } = require('../build-status')
const t = (module.exports = require('../tester').createServiceTester())
@@ -9,28 +8,32 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('release status is succeeded')
.get('/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/1/1.json')
.expectJSONTypes(
Joi.object().keys({
name: 'deployment',
value: isBuildStatus,
})
)
.expectBadge({
label: 'deployment',
message: isBuildStatus,
})
t.create('unknown environment')
.get('/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/1/515.json')
.expectJSON({ name: 'deployment', value: 'user or environment not found' })
.expectBadge({
label: 'deployment',
message: 'user or environment not found',
})
t.create('unknown definition')
.get('/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/515/515.json')
.expectJSON({
name: 'deployment',
value: 'inaccessible or definition not found',
.expectBadge({
label: 'deployment',
message: 'inaccessible or definition not found',
})
t.create('unknown project')
.get('/totodem/515/515/515.json')
.expectJSON({ name: 'deployment', value: 'project not found' })
.expectBadge({ label: 'deployment', message: 'project not found' })
t.create('unknown user')
.get('/this-repo/does-not-exist/1/2.json')
.expectJSON({ name: 'deployment', value: 'user or environment not found' })
.expectBadge({
label: 'deployment',
message: 'user or environment not found',
})

View File

@@ -116,7 +116,7 @@ const isCompactCustomAzureDevOpsTestTotals = isAzureDevOpsTestTotals(
t.create('unknown build definition')
.get(`${uriPrefix}/${nonExistentDefinitionId}.json`)
.expectJSON({ name: 'tests', value: 'build pipeline not found' })
.expectBadge({ label: 'tests', message: 'build pipeline not found' })
t.create('404 latest build error response')
.get(mockBadgeUri)
@@ -125,9 +125,9 @@ t.create('404 latest build error response')
.get(mockLatestBuildApiUriPath)
.reply(404)
)
.expectJSON({
name: 'tests',
value: 'build pipeline or test result summary not found',
.expectBadge({
label: 'tests',
message: 'build pipeline or test result summary not found',
})
t.create('no build response')
@@ -140,7 +140,7 @@ t.create('no build response')
value: [],
})
)
.expectJSON({ name: 'tests', value: 'build pipeline not found' })
.expectBadge({ label: 'tests', message: 'build pipeline not found' })
t.create('no test result summary response')
.get(mockBadgeUri)
@@ -151,9 +151,9 @@ t.create('no test result summary response')
.get(mockTestResultSummaryApiUriPath)
.reply(404)
)
.expectJSON({
name: 'tests',
value: 'build pipeline or test result summary not found',
.expectBadge({
label: 'tests',
message: 'build pipeline or test result summary not found',
})
t.create('invalid test result summary response')
@@ -165,7 +165,7 @@ t.create('invalid test result summary response')
.get(mockTestResultSummaryApiUriPath)
.reply(200, {})
)
.expectJSON({ name: 'tests', value: 'invalid response data' })
.expectBadge({ label: 'tests', message: 'invalid response data' })
t.create('no tests in test result summary response')
.get(mockBadgeUri)
@@ -176,27 +176,23 @@ t.create('no tests in test result summary response')
.get(mockTestResultSummaryApiUriPath)
.reply(200, mockEmptyTestResultSummaryResponse)
)
.expectJSON({ name: 'tests', value: 'no tests' })
.expectBadge({ label: 'tests', message: 'no tests' })
t.create('test status')
.get(mockBadgeUri)
.intercept(mockTestResultSummarySetup)
.expectJSONTypes(
Joi.object().keys({
name: 'tests',
value: expectedDefaultAzureDevOpsTestTotals,
})
)
.expectBadge({
label: 'tests',
message: expectedDefaultAzureDevOpsTestTotals,
})
t.create('test status on branch')
.get(mockBranchBadgeUri)
.intercept(mockBranchTestResultSummarySetup)
.expectJSONTypes(
Joi.object().keys({
name: 'tests',
value: expectedDefaultAzureDevOpsTestTotals,
})
)
.expectBadge({
label: 'tests',
message: expectedDefaultAzureDevOpsTestTotals,
})
t.create('test status with compact message')
.get(mockBadgeUri, {
@@ -205,12 +201,10 @@ t.create('test status with compact message')
},
})
.intercept(mockTestResultSummarySetup)
.expectJSONTypes(
Joi.object().keys({
name: 'tests',
value: expectedCompactAzureDevOpsTestTotals,
})
)
.expectBadge({
label: 'tests',
message: expectedCompactAzureDevOpsTestTotals,
})
t.create('test status with custom labels')
.get(mockBadgeUri, {
@@ -221,12 +215,10 @@ t.create('test status with custom labels')
},
})
.intercept(mockTestResultSummarySetup)
.expectJSONTypes(
Joi.object().keys({
name: 'tests',
value: expectedCustomAzureDevOpsTestTotals,
})
)
.expectBadge({
label: 'tests',
message: expectedCustomAzureDevOpsTestTotals,
})
t.create('test status with compact message and custom labels')
.get(mockBadgeUri, {
@@ -238,24 +230,18 @@ t.create('test status with compact message and custom labels')
},
})
.intercept(mockTestResultSummarySetup)
.expectJSONTypes(
Joi.object().keys({
name: 'tests',
value: expectedCompactCustomAzureDevOpsTestTotals,
})
)
.expectBadge({
label: 'tests',
message: expectedCompactCustomAzureDevOpsTestTotals,
})
t.create('live test status')
.get(mockBadgeUri)
.expectJSONTypes(
Joi.object().keys({ name: 'tests', value: isDefaultAzureDevOpsTestTotals })
)
.expectBadge({ label: 'tests', message: isDefaultAzureDevOpsTestTotals })
t.create('live test status on branch')
.get(mockBranchBadgeUri)
.expectJSONTypes(
Joi.object().keys({ name: 'tests', value: isDefaultAzureDevOpsTestTotals })
)
.expectBadge({ label: 'tests', message: isDefaultAzureDevOpsTestTotals })
t.create('live test status with compact message')
.get(mockBadgeUri, {
@@ -263,9 +249,7 @@ t.create('live test status with compact message')
compact_message: null,
},
})
.expectJSONTypes(
Joi.object().keys({ name: 'tests', value: isCompactAzureDevOpsTestTotals })
)
.expectBadge({ label: 'tests', message: isCompactAzureDevOpsTestTotals })
t.create('live test status with custom labels')
.get(mockBadgeUri, {
@@ -275,9 +259,7 @@ t.create('live test status with custom labels')
skipped_label: 'n/a',
},
})
.expectJSONTypes(
Joi.object().keys({ name: 'tests', value: isCustomAzureDevOpsTestTotals })
)
.expectBadge({ label: 'tests', message: isCustomAzureDevOpsTestTotals })
t.create('live test status with compact message and custom labels')
.get(mockBadgeUri, {
@@ -288,9 +270,7 @@ t.create('live test status with compact message and custom labels')
skipped_label: '🤷',
},
})
.expectJSONTypes(
Joi.object().keys({
name: 'tests',
value: isCompactCustomAzureDevOpsTestTotals,
})
)
.expectBadge({
label: 'tests',
message: isCompactCustomAzureDevOpsTestTotals,
})

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { withRegex } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
@@ -8,16 +7,14 @@ const amountOfMoney = withRegex(/^\$[0-9]+(\.[0-9]+)?/)
t.create('funding')
.get('/hashdog/scrapfy-chrome-extension.json')
.expectJSONTypes(
Joi.object().keys({
name: 'beerpay',
value: amountOfMoney,
})
)
.expectBadge({
label: 'beerpay',
message: amountOfMoney,
})
t.create('funding (unknown project)')
.get('/hashdog/not-a-real-project.json')
.expectJSON({
name: 'beerpay',
value: 'project not found',
.expectBadge({
label: 'beerpay',
message: 'project not found',
})

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const {
isVPlusDottedVersionNClausesWithOptionalSuffix,
} = require('../test-validators')
@@ -8,21 +7,17 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('version')
.get('/asciidoctor/maven/asciidoctorj.json')
.expectJSONTypes(
Joi.object().keys({
name: 'bintray',
value: isVPlusDottedVersionNClausesWithOptionalSuffix,
})
)
.expectBadge({
label: 'bintray',
message: isVPlusDottedVersionNClausesWithOptionalSuffix,
})
t.create('version (not found)')
.get('/asciidoctor/maven/not-a-real-package.json')
.expectJSONTypes(
Joi.object().keys({
name: 'bintray',
value: 'not found',
})
)
.expectBadge({
label: 'bintray',
message: 'not found',
})
t.create('version (mocked)')
.get('/asciidoctor/maven/asciidoctorj.json?style=_shields_test')
@@ -33,8 +28,8 @@ t.create('version (mocked)')
name: '1.5.7',
})
)
.expectJSON({
name: 'bintray',
value: 'v1.5.7',
.expectBadge({
label: 'bintray',
message: 'v1.5.7',
color: 'blue',
})

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { ServiceTester } = require('../tester')
const { isMetric, isMetricOpenIssues } = require('../test-validators')
const { isBuildStatus } = require('../build-status')
@@ -21,73 +20,65 @@ const t = (module.exports = new ServiceTester({
t.create('issues-raw (valid)')
.get('/issues-raw/atlassian/python-bitbucket.json')
.expectJSONTypes(
Joi.object().keys({
name: 'issues',
value: isMetric,
})
)
.expectBadge({
label: 'issues',
message: isMetric,
})
t.create('issues-raw (not found)')
.get('/issues-raw/atlassian/not-a-repo.json')
.expectJSON({ name: 'issues', value: 'not found' })
.expectBadge({ label: 'issues', message: 'not found' })
t.create('issues-raw (private repo)')
.get('/issues-raw/chris48s/example-private-repo.json')
.expectJSON({ name: 'issues', value: 'private repo' })
.expectBadge({ label: 'issues', message: 'private repo' })
t.create('issues (valid)')
.get('/issues/atlassian/python-bitbucket.json')
.expectJSONTypes(
Joi.object().keys({
name: 'issues',
value: isMetricOpenIssues,
})
)
.expectBadge({
label: 'issues',
message: isMetricOpenIssues,
})
t.create('issues (not found)')
.get('/issues/atlassian/not-a-repo.json')
.expectJSON({ name: 'issues', value: 'not found' })
.expectBadge({ label: 'issues', message: 'not found' })
t.create('issues (private repo)')
.get('/issues/chris48s/example-private-repo.json')
.expectJSON({ name: 'issues', value: 'private repo' })
.expectBadge({ label: 'issues', message: 'private repo' })
// tests for pull requests endpoints
t.create('pr-raw (valid)')
.get('/pr-raw/atlassian/python-bitbucket.json')
.expectJSONTypes(
Joi.object().keys({
name: 'pull requests',
value: isMetric,
})
)
.expectBadge({
label: 'pull requests',
message: isMetric,
})
t.create('pr-raw (not found)')
.get('/pr-raw/atlassian/not-a-repo.json')
.expectJSON({ name: 'pull requests', value: 'not found' })
.expectBadge({ label: 'pull requests', message: 'not found' })
t.create('pr-raw (private repo)')
.get('/pr-raw/chris48s/example-private-repo.json')
.expectJSON({ name: 'pull requests', value: 'private repo' })
.expectBadge({ label: 'pull requests', message: 'private repo' })
t.create('pr (valid)')
.get('/pr/atlassian/python-bitbucket.json')
.expectJSONTypes(
Joi.object().keys({
name: 'pull requests',
value: isMetricOpenIssues,
})
)
.expectBadge({
label: 'pull requests',
message: isMetricOpenIssues,
})
t.create('pr (not found)')
.get('/pr/atlassian/not-a-repo.json')
.expectJSON({ name: 'pull requests', value: 'not found' })
.expectBadge({ label: 'pull requests', message: 'not found' })
t.create('pr (private repo)')
.get('/pr/chris48s/example-private-repo.json')
.expectJSON({ name: 'pull requests', value: 'private repo' })
.expectBadge({ label: 'pull requests', message: 'private repo' })
t.create('pr (server)')
.get('/pr/project/repo.json?server=https://bitbucket.mydomain.net')
@@ -102,12 +93,10 @@ t.create('pr (server)')
})
.reply(200, { size: 42 })
)
.expectJSONTypes(
Joi.object().keys({
name: 'pull requests',
value: isMetricOpenIssues,
})
)
.expectBadge({
label: 'pull requests',
message: isMetricOpenIssues,
})
t.create('pr (server, invalid credentials)')
.get('/pr/project/repo.json?server=https://bitbucket.mydomain.net')
@@ -122,12 +111,10 @@ t.create('pr (server, invalid credentials)')
})
.reply(401)
)
.expectJSONTypes(
Joi.object().keys({
name: 'pull requests',
value: 'invalid credentials',
})
)
.expectBadge({
label: 'pull requests',
message: 'invalid credentials',
})
t.create('pr (server, private repo)')
.get('/pr/project/repo.json?server=https://bitbucket.mydomain.net')
@@ -142,12 +129,10 @@ t.create('pr (server, private repo)')
})
.reply(403)
)
.expectJSONTypes(
Joi.object().keys({
name: 'pull requests',
value: 'private repo',
})
)
.expectBadge({
label: 'pull requests',
message: 'private repo',
})
t.create('pr (server, not found)')
.get('/pr/project/repo.json?server=https://bitbucket.mydomain.net')
@@ -162,12 +147,10 @@ t.create('pr (server, not found)')
})
.reply(404)
)
.expectJSONTypes(
Joi.object().keys({
name: 'pull requests',
value: 'not found',
})
)
.expectBadge({
label: 'pull requests',
message: 'not found',
})
t.create('pr (auth)')
.before(mockBitbucketCreds)
@@ -179,12 +162,10 @@ t.create('pr (auth)')
.reply(200, { size: 42 })
)
.finally(restore)
.expectJSONTypes(
Joi.object().keys({
name: 'pull requests',
value: isMetricOpenIssues,
})
)
.expectBadge({
label: 'pull requests',
message: isMetricOpenIssues,
})
t.create('pr (server, auth)')
.before(mockBitbucketServerCreds)
@@ -196,12 +177,10 @@ t.create('pr (server, auth)')
.reply(200, { size: 42 })
)
.finally(restore)
.expectJSONTypes(
Joi.object().keys({
name: 'pull requests',
value: isMetricOpenIssues,
})
)
.expectBadge({
label: 'pull requests',
message: isMetricOpenIssues,
})
// tests for Bitbucket Pipelines
function bitbucketApiResponse(status) {
@@ -223,35 +202,31 @@ function bitbucketApiResponse(status) {
t.create('master build result (valid)')
.get('/pipelines/atlassian/adf-builder-javascript.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: isBuildStatus,
})
)
.expectBadge({
label: 'build',
message: isBuildStatus,
})
t.create('master build result (not found)')
.get('/pipelines/atlassian/not-a-repo.json')
.expectJSON({ name: 'build', value: 'not found' })
.expectBadge({ label: 'build', message: 'not found' })
t.create('branch build result (valid)')
.get(
'/pipelines/atlassian/adf-builder-javascript/shields-test-dont-remove.json'
)
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: isBuildStatus,
})
)
.expectBadge({
label: 'build',
message: isBuildStatus,
})
t.create('branch build result (not found)')
.get('/pipelines/atlassian/not-a-repo/some-branch.json')
.expectJSON({ name: 'build', value: 'not found' })
.expectBadge({ label: 'build', message: 'not found' })
t.create('branch build result (never built)')
.get('/pipelines/atlassian/adf-builder-javascript/some/new/branch.json')
.expectJSON({ name: 'build', value: 'never built' })
.expectBadge({ label: 'build', message: 'never built' })
t.create('build result (passing)')
.get('/pipelines/atlassian/adf-builder-javascript.json')
@@ -260,7 +235,7 @@ t.create('build result (passing)')
.get(/^\/2.0\/.*/)
.reply(200, bitbucketApiResponse('SUCCESSFUL'))
)
.expectJSON({ name: 'build', value: 'passing' })
.expectBadge({ label: 'build', message: 'passing' })
t.create('build result (failing)')
.get('/pipelines/atlassian/adf-builder-javascript.json')
@@ -269,7 +244,7 @@ t.create('build result (failing)')
.get(/^\/2.0\/.*/)
.reply(200, bitbucketApiResponse('FAILED'))
)
.expectJSON({ name: 'build', value: 'failing' })
.expectBadge({ label: 'build', message: 'failing' })
t.create('build result (error)')
.get('/pipelines/atlassian/adf-builder-javascript.json')
@@ -278,7 +253,7 @@ t.create('build result (error)')
.get(/^\/2.0\/.*/)
.reply(200, bitbucketApiResponse('ERROR'))
)
.expectJSON({ name: 'build', value: 'error' })
.expectBadge({ label: 'build', message: 'error' })
t.create('build result (stopped)')
.get('/pipelines/atlassian/adf-builder-javascript.json')
@@ -287,7 +262,7 @@ t.create('build result (stopped)')
.get(/^\/2.0\/.*/)
.reply(200, bitbucketApiResponse('STOPPED'))
)
.expectJSON({ name: 'build', value: 'stopped' })
.expectBadge({ label: 'build', message: 'stopped' })
t.create('build result (expired)')
.get('/pipelines/atlassian/adf-builder-javascript.json')
@@ -296,7 +271,7 @@ t.create('build result (expired)')
.get(/^\/2.0\/.*/)
.reply(200, bitbucketApiResponse('EXPIRED'))
)
.expectJSON({ name: 'build', value: 'expired' })
.expectBadge({ label: 'build', message: 'expired' })
t.create('build result (unexpected status)')
.get('/pipelines/atlassian/adf-builder-javascript.json')
@@ -305,4 +280,4 @@ t.create('build result (unexpected status)')
.get(/^\/2.0\/.*/)
.reply(200, bitbucketApiResponse('NEW_AND_UNEXPECTED'))
)
.expectJSON({ name: 'build', value: 'invalid response data' })
.expectBadge({ label: 'build', message: 'invalid response data' })

View File

@@ -9,21 +9,21 @@ const t = (module.exports = new ServiceTester({
t.create('no longer available (code)')
.get('/code/github/rexxars/sse-channel.json')
.expectJSON({
name: 'bithound',
value: 'no longer available',
.expectBadge({
label: 'bithound',
message: 'no longer available',
})
t.create('no longer available (dependencies)')
.get('/dependencies/github/rexxars/sse-channel.json')
.expectJSON({
name: 'bithound',
value: 'no longer available',
.expectBadge({
label: 'bithound',
message: 'no longer available',
})
t.create('no longer available (devDpendencies)')
.get('/devDependencies/github/rexxars/sse-channel.json')
.expectJSON({
name: 'bithound',
value: 'no longer available',
.expectBadge({
label: 'bithound',
message: 'no longer available',
})

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { isMetric } = require('../test-validators')
const { ServiceTester } = require('../tester')
@@ -11,16 +10,14 @@ const t = (module.exports = new ServiceTester({
t.create('bounties (valid)')
.get('/team/mozilla-core/activity.json')
.expectJSONTypes(
Joi.object().keys({
name: 'bounties',
value: isMetric,
})
)
.expectBadge({
label: 'bounties',
message: isMetric,
})
t.create('bounties (invalid team)')
.get('/team/not-a-real-team/activity.json')
.expectJSON({
name: 'bounties',
value: 'not found',
.expectBadge({
label: 'bounties',
message: 'not found',
})

View File

@@ -5,7 +5,7 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('licence')
.timeout(10000)
.get('/bootstrap.json')
.expectJSON({ name: 'license', value: 'MIT' })
.expectBadge({ label: 'license', message: 'MIT' })
t.create('license not declared')
.get('/bootstrap.json')
@@ -14,9 +14,9 @@ t.create('license not declared')
.get('/api/bower/bootstrap')
.reply(200, { normalized_licenses: [] })
)
.expectJSON({ name: 'license', value: 'missing' })
.expectBadge({ label: 'license', message: 'missing' })
t.create('licence for Invalid Package')
.timeout(10000)
.get('/it-is-a-invalid-package-should-error.json')
.expectJSON({ name: 'license', value: 'package not found' })
.expectBadge({ label: 'license', message: 'package not found' })

View File

@@ -11,32 +11,28 @@ const isBowerPrereleaseVersion = Joi.string().regex(
t.create('version')
.timeout(10000)
.get('/v/bootstrap.json')
.expectJSONTypes(
Joi.object().keys({
name: 'bower',
value: isVPlusDottedVersionAtLeastOne,
})
)
.expectBadge({
label: 'bower',
message: isVPlusDottedVersionAtLeastOne,
})
t.create('pre version') // e.g. bower|v0.2.5-alpha-rc-pre
.timeout(10000)
.get('/vpre/bootstrap.json')
.expectJSONTypes(
Joi.object().keys({
name: 'bower',
value: isBowerPrereleaseVersion,
})
)
.expectBadge({
label: 'bower',
message: isBowerPrereleaseVersion,
})
t.create('Version for Invalid Package')
.timeout(10000)
.get('/v/it-is-a-invalid-package-should-error.json')
.expectJSON({ name: 'bower', value: 'package not found' })
.expectBadge({ label: 'bower', message: 'package not found' })
t.create('Pre Version for Invalid Package')
.timeout(10000)
.get('/vpre/it-is-a-invalid-package-should-error.json')
.expectJSON({ name: 'bower', value: 'package not found' })
.expectBadge({ label: 'bower', message: 'package not found' })
t.create('Version label should be `no releases` if no stable version')
.get('/v/bootstrap.json')
@@ -45,7 +41,7 @@ t.create('Version label should be `no releases` if no stable version')
.get('/api/bower/bootstrap')
.reply(200, { normalized_licenses: [], latest_stable_release: null })
)
.expectJSON({ name: 'bower', value: 'no releases' })
.expectBadge({ label: 'bower', message: 'no releases' })
t.create('Version label should be `no releases` if no pre-release')
.get('/vpre/bootstrap.json')
@@ -54,4 +50,4 @@ t.create('Version label should be `no releases` if no pre-release')
.get('/api/bower/bootstrap')
.reply(200, { normalized_licenses: [], latest_release_number: null })
)
.expectJSON({ name: 'bower', value: 'no releases' })
.expectBadge({ label: 'bower', message: 'no releases' })

View File

@@ -1,14 +1,11 @@
'use strict'
const Joi = require('joi')
const { isMetric } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('Players')
.get('/1.json')
.expectJSONTypes(
Joi.object().keys({
name: 'players',
value: isMetric,
})
)
.expectBadge({
label: 'players',
message: isMetric,
})

View File

@@ -1,14 +1,11 @@
'use strict'
const Joi = require('joi')
const { isMetric } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('Servers')
.get('/1.json')
.expectJSONTypes(
Joi.object().keys({
name: 'servers',
value: isMetric,
})
)
.expectBadge({
label: 'servers',
message: isMetric,
})

View File

@@ -17,13 +17,11 @@ const bzBugStatus = Joi.equal(
t.create('Bugzilla valid bug status')
.get('/996038.json')
.expectJSONTypes(
Joi.object().keys({
name: 'bug 996038',
value: bzBugStatus,
})
)
.expectBadge({
label: 'bug 996038',
message: bzBugStatus,
})
t.create('Bugzilla invalid bug status')
.get('/83548978974387943879.json')
.expectJSON({ name: 'bugzilla', value: 'not found' })
.expectBadge({ label: 'bugzilla', message: 'not found' })

View File

@@ -12,36 +12,32 @@ const t = (module.exports = new ServiceTester({
t.create('buildkite invalid pipeline')
.get('/unknown-identifier/unknown-branch.json')
.expectJSON({ name: 'build', value: 'not found' })
.expectBadge({ label: 'build', message: 'not found' })
t.create('buildkite valid pipeline')
.get('/3826789cf8890b426057e6fe1c4e683bdf04fa24d498885489/master.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
})
)
.expectBadge({
label: 'build',
message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
})
t.create('buildkite valid pipeline skipping branch')
.get('/3826789cf8890b426057e6fe1c4e683bdf04fa24d498885489.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
})
)
.expectBadge({
label: 'build',
message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
})
t.create('buildkite unknown branch')
.get(
'/3826789cf8890b426057e6fe1c4e683bdf04fa24d498885489/unknown-branch.json'
)
.expectJSON({ name: 'build', value: 'unknown' })
.expectBadge({ label: 'build', message: 'unknown' })
t.create('buildkite connection error')
.get('/_.json')
.networkOff()
.expectJSON({ name: 'build', value: 'inaccessible' })
.expectBadge({ label: 'build', message: 'inaccessible' })
t.create('buildkite unexpected response')
.get('/3826789cf8890b426057e6fe1c4e683bdf04fa24d498885489.json')
@@ -52,4 +48,4 @@ t.create('buildkite unexpected response')
)
.reply(invalidJSON)
)
.expectJSON({ name: 'build', value: 'invalid' })
.expectBadge({ label: 'build', message: 'invalid' })

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { isFileSize } = require('../test-validators')
const { ServiceTester } = require('../tester')
@@ -20,57 +19,57 @@ const data = [
{
format: formats.A,
get: '/min/preact.json',
expect: { name: 'minified size', value: isFileSize },
expect: { label: 'minified size', message: isFileSize },
},
{
format: formats.B,
get: '/min/preact/8.0.0.json',
expect: { name: 'minified size', value: isFileSize },
expect: { label: 'minified size', message: isFileSize },
},
{
format: formats.C,
get: '/min/@cycle/core.json',
expect: { name: 'minified size', value: isFileSize },
expect: { label: 'minified size', message: isFileSize },
},
{
format: formats.D,
get: '/min/@cycle/core/7.0.0.json',
expect: { name: 'minified size', value: isFileSize },
expect: { label: 'minified size', message: isFileSize },
},
{
format: formats.A,
get: '/minzip/preact.json',
expect: { name: 'minzipped size', value: isFileSize },
expect: { label: 'minzipped size', message: isFileSize },
},
{
format: formats.B,
get: '/minzip/preact/8.0.0.json',
expect: { name: 'minzipped size', value: isFileSize },
expect: { label: 'minzipped size', message: isFileSize },
},
{
format: formats.C,
get: '/minzip/@cycle/core.json',
expect: { name: 'minzipped size', value: isFileSize },
expect: { label: 'minzipped size', message: isFileSize },
},
{
format: formats.D,
get: '/minzip/@cycle/core/7.0.0.json',
expect: { name: 'minzipped size', value: isFileSize },
expect: { label: 'minzipped size', message: isFileSize },
},
{
format: formats.A,
get: '/min/some-no-exist.json',
expect: { name: 'minified size', value: 'package not found error' },
expect: { label: 'minified size', message: 'package not found error' },
},
{
format: formats.C,
get: '/min/@some-no-exist/some-no-exist.json',
expect: { name: 'minified size', value: 'package not found error' },
expect: { label: 'minified size', message: 'package not found error' },
},
]
data.forEach(({ format, get, expect }) => {
t.create(`Testing format '${format}' against '${get}'`)
.get(get)
.expectJSONTypes(Joi.object().keys(expect))
.expectBadge(expect)
})

View File

@@ -9,7 +9,7 @@ const t = (module.exports = new ServiceTester({
t.create('no longer available')
.get('/mi/matthiasmullie/scrapbook/master.json')
.expectJSON({
name: 'cauditor',
value: 'no longer available',
.expectBadge({
label: 'cauditor',
message: 'no longer available',
})

View File

@@ -1,18 +1,15 @@
'use strict'
const Joi = require('joi')
const { isVPlusTripleDottedVersion } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('cdnjs (valid)')
.get('/jquery.json')
.expectJSONTypes(
Joi.object().keys({
name: 'cdnjs',
value: isVPlusTripleDottedVersion,
})
)
.expectBadge({
label: 'cdnjs',
message: isVPlusTripleDottedVersion,
})
t.create('cdnjs (not found)')
.get('/not-a-library.json')
.expectJSON({ name: 'cdnjs', value: 'not found' })
.expectBadge({ label: 'cdnjs', message: 'not found' })

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const {
isMetric,
isVPlusDottedVersionNClauses,
@@ -17,43 +16,37 @@ const t = (module.exports = new ServiceTester({
t.create('total downloads (valid)')
.get('/dt/scriptcs.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: isMetric,
})
)
.expectBadge({
label: 'downloads',
message: isMetric,
})
t.create('total downloads (not found)')
.get('/dt/not-a-real-package.json')
.expectJSON({ name: 'downloads', value: 'not found' })
.expectBadge({ label: 'downloads', message: 'not found' })
// version
t.create('version (valid)')
.get('/v/scriptcs.json')
.expectJSONTypes(
Joi.object().keys({
name: 'chocolatey',
value: isVPlusDottedVersionNClauses,
})
)
.expectBadge({
label: 'chocolatey',
message: isVPlusDottedVersionNClauses,
})
t.create('version (not found)')
.get('/v/not-a-real-package.json')
.expectJSON({ name: 'chocolatey', value: 'not found' })
.expectBadge({ label: 'chocolatey', message: 'not found' })
// version (pre)
t.create('version (pre) (valid)')
.get('/vpre/scriptcs.json')
.expectJSONTypes(
Joi.object().keys({
name: 'chocolatey',
value: isVPlusDottedVersionNClausesWithOptionalSuffix,
})
)
.expectBadge({
label: 'chocolatey',
message: isVPlusDottedVersionNClausesWithOptionalSuffix,
})
t.create('version (pre) (not found)')
.get('/vpre/not-a-real-package.json')
.expectJSON({ name: 'chocolatey', value: 'not found' })
.expectBadge({ label: 'chocolatey', message: 'not found' })

View File

@@ -15,48 +15,42 @@ const t = (module.exports = new ServiceTester({
t.create('Downloads (now users)')
.get('/d/alhjnofcnnpeaphgeakdhkebafjcpeae.json')
.expectJSONTypes(Joi.object().keys({ name: 'users', value: isMetric }))
.expectBadge({ label: 'users', message: isMetric })
t.create('Users')
.get('/users/alhjnofcnnpeaphgeakdhkebafjcpeae.json')
.expectJSONTypes(Joi.object().keys({ name: 'users', value: isMetric }))
.expectBadge({ label: 'users', message: isMetric })
t.create('Version')
.get('/v/alhjnofcnnpeaphgeakdhkebafjcpeae.json')
.expectJSONTypes(
Joi.object().keys({
name: 'chrome web store',
value: isVPlusDottedVersionAtLeastOne,
})
)
.expectBadge({
label: 'chrome web store',
message: isVPlusDottedVersionAtLeastOne,
})
t.create('Version - Custom label')
.get('/v/alhjnofcnnpeaphgeakdhkebafjcpeae.json?label=IndieGala Helper')
.expectJSONTypes(
Joi.object().keys({
name: 'IndieGala Helper',
value: isVPlusDottedVersionAtLeastOne,
})
)
.expectBadge({
label: 'IndieGala Helper',
message: isVPlusDottedVersionAtLeastOne,
})
t.create('Rating')
.get('/rating/alhjnofcnnpeaphgeakdhkebafjcpeae.json')
.expectJSONTypes(
Joi.object().keys({
name: 'rating',
value: Joi.string().regex(/^\d\.?\d+?\/5$/),
})
)
.expectBadge({
label: 'rating',
message: Joi.string().regex(/^\d\.?\d+?\/5$/),
})
t.create('Stars')
.get('/stars/alhjnofcnnpeaphgeakdhkebafjcpeae.json')
.expectJSONTypes(Joi.object().keys({ name: 'rating', value: isStarRating }))
.expectBadge({ label: 'rating', message: isStarRating })
t.create('Invalid addon')
.get('/d/invalid-name-of-addon.json')
.expectJSON({ name: 'chrome web store', value: 'invalid' })
.expectBadge({ label: 'chrome web store', message: 'invalid' })
t.create('No connection')
.get('/v/alhjnofcnnpeaphgeakdhkebafjcpeae.json')
.networkOff()
.expectJSON({ name: 'chrome web store', value: 'inaccessible' })
.expectBadge({ label: 'chrome web store', message: 'inaccessible' })

View File

@@ -1,39 +1,32 @@
'use strict'
const Joi = require('joi')
const { withRegex } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('live: level known project')
.get(`/level/1.json`)
.expectJSONTypes(
Joi.object().keys({
name: 'cii',
value: withRegex(/in progress|passing|silver|gold/),
})
)
.expectBadge({
label: 'cii',
message: withRegex(/in progress|passing|silver|gold/),
})
t.create('live: percentage known project')
.get(`/percentage/29.json`)
.expectJSONTypes(
Joi.object().keys({
name: 'cii',
value: withRegex(/([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|300)%/),
})
)
.expectBadge({
label: 'cii',
message: withRegex(/([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|300)%/),
})
t.create('live: summary known project')
.get(`/summary/33.json`)
.expectJSONTypes(
Joi.object().keys({
name: 'cii',
value: withRegex(/(in progress [0-9]|[1-9][0-9]%)|passing|silver|gold/),
})
)
.expectBadge({
label: 'cii',
message: withRegex(/(in progress [0-9]|[1-9][0-9]%)|passing|silver|gold/),
})
t.create('live: unknown project')
.get(`/level/abc.json`)
.expectJSON({ name: 'cii', value: 'project not found' })
.expectBadge({ label: 'cii', message: 'project not found' })
t.create('level: gold project')
.get(`/level/1.json`)
@@ -45,9 +38,9 @@ t.create('level: gold project')
tiered_percentage: 300,
})
)
.expectJSON({
name: 'cii',
value: 'gold',
.expectBadge({
label: 'cii',
message: 'gold',
})
t.create('level: silver project')
@@ -60,9 +53,9 @@ t.create('level: silver project')
tiered_percentage: 297,
})
)
.expectJSON({
name: 'cii',
value: 'silver',
.expectBadge({
label: 'cii',
message: 'silver',
})
t.create('level: passing project')
@@ -75,9 +68,9 @@ t.create('level: passing project')
tiered_percentage: 107,
})
)
.expectJSON({
name: 'cii',
value: 'passing',
.expectBadge({
label: 'cii',
message: 'passing',
})
t.create('level: in progress project')
@@ -90,9 +83,9 @@ t.create('level: in progress project')
tiered_percentage: 94,
})
)
.expectJSON({
name: 'cii',
value: 'in progress',
.expectBadge({
label: 'cii',
message: 'in progress',
})
t.create('percentage: gold project')
@@ -105,9 +98,9 @@ t.create('percentage: gold project')
tiered_percentage: 300,
})
)
.expectJSON({
name: 'cii',
value: '300%',
.expectBadge({
label: 'cii',
message: '300%',
})
t.create('percentage: silver project')
@@ -120,9 +113,9 @@ t.create('percentage: silver project')
tiered_percentage: 297,
})
)
.expectJSON({
name: 'cii',
value: '297%',
.expectBadge({
label: 'cii',
message: '297%',
})
t.create('percentage: passing project')
@@ -135,9 +128,9 @@ t.create('percentage: passing project')
tiered_percentage: 107,
})
)
.expectJSON({
name: 'cii',
value: '107%',
.expectBadge({
label: 'cii',
message: '107%',
})
t.create('percentage: in progress project')
@@ -150,9 +143,9 @@ t.create('percentage: in progress project')
tiered_percentage: 94,
})
)
.expectJSON({
name: 'cii',
value: '94%',
.expectBadge({
label: 'cii',
message: '94%',
})
t.create('summary: gold project')
@@ -165,9 +158,9 @@ t.create('summary: gold project')
tiered_percentage: 300,
})
)
.expectJSON({
name: 'cii',
value: 'gold',
.expectBadge({
label: 'cii',
message: 'gold',
})
t.create('summary: silver project')
@@ -180,9 +173,9 @@ t.create('summary: silver project')
tiered_percentage: 297,
})
)
.expectJSON({
name: 'cii',
value: 'silver',
.expectBadge({
label: 'cii',
message: 'silver',
})
t.create('summary: passing project')
@@ -195,9 +188,9 @@ t.create('summary: passing project')
tiered_percentage: 107,
})
)
.expectJSON({
name: 'cii',
value: 'passing',
.expectBadge({
label: 'cii',
message: 'passing',
})
t.create('summary: in progress project')
@@ -210,7 +203,7 @@ t.create('summary: in progress project')
tiered_percentage: 94,
})
)
.expectJSON({
name: 'cii',
value: 'in progress 94%',
.expectBadge({
label: 'cii',
message: 'in progress 94%',
})

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { isBuildStatus } = require('../build-status')
const { ServiceTester } = require('../tester')
@@ -11,45 +10,37 @@ const t = (module.exports = new ServiceTester({
t.create('circle ci (valid, without branch)')
.get('/project/github/RedSparr0w/node-csgo-parser.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: isBuildStatus,
})
)
.expectBadge({
label: 'build',
message: isBuildStatus,
})
t.create('circle ci (valid, with branch)')
.get('/project/github/RedSparr0w/node-csgo-parser/master.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: isBuildStatus,
})
)
.expectBadge({
label: 'build',
message: isBuildStatus,
})
t.create('build status with "github" as a default VCS')
.get('/project/RedSparr0w/node-csgo-parser/master.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: isBuildStatus,
})
)
.expectBadge({
label: 'build',
message: isBuildStatus,
})
t.create('circle ci (valid, with token)')
.get(
'/token/b90b5c49e59a4c67ba3a92f7992587ac7a0408c2/project/github/RedSparr0w/node-csgo-parser/master.json'
)
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: isBuildStatus,
})
)
.expectBadge({
label: 'build',
message: isBuildStatus,
})
t.create('circle ci (not found)')
.get('/project/github/PyvesB/EmptyRepo.json')
.expectJSON({ name: 'build', value: 'project not found' })
.expectBadge({ label: 'build', message: 'project not found' })
t.create('circle ci (no response data)')
.get('/project/github/RedSparr0w/node-csgo-parser.json')
@@ -60,7 +51,7 @@ t.create('circle ci (no response data)')
)
.reply(200)
)
.expectJSON({ name: 'build', value: 'unparseable json response' })
.expectBadge({ label: 'build', message: 'unparseable json response' })
// we're passing &limit=1 so we expect exactly one array element
t.create('circle ci (invalid json)')
@@ -72,8 +63,8 @@ t.create('circle ci (invalid json)')
)
.reply(200, [{ status: 'success' }, { status: 'fixed' }])
)
.expectJSON({
name: 'build',
value: 'invalid response data',
.expectBadge({
label: 'build',
message: 'invalid response data',
color: 'lightgrey',
})

View File

@@ -1,18 +1,15 @@
'use strict'
const Joi = require('joi')
const { isMetric } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('clojars downloads (valid)')
.get('/prismic.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: isMetric,
})
)
.expectBadge({
label: 'downloads',
message: isMetric,
})
t.create('clojars downloads (not found)')
.get('/not-a-package.json')
.expectJSON({ name: 'downloads', value: 'not found' })
.expectBadge({ label: 'downloads', message: 'not found' })

View File

@@ -1,17 +1,14 @@
'use strict'
const Joi = require('joi')
const t = (module.exports = require('../tester').createServiceTester())
t.create('clojars (valid)')
.get('/prismic.json')
.expectJSONTypes(
Joi.object().keys({
name: 'clojars',
value: /^\[prismic "([0-9][.]?)+"\]$/, // note: https://github.com/badges/shields/pull/431
})
)
.expectBadge({
label: 'clojars',
message: /^\[prismic "([0-9][.]?)+"\]$/, // note: https://github.com/badges/shields/pull/431
})
t.create('clojars (not found)')
.get('/not-a-package.json')
.expectJSON({ name: 'clojars', value: 'not found' })
.expectBadge({ label: 'clojars', message: 'not found' })

View File

@@ -9,12 +9,12 @@ const t = (module.exports = new ServiceTester({
t.create('apps (valid, weekly)')
.get('/aw/AFNetworking.json')
.expectJSON({ name: 'apps', value: 'no longer available' })
.expectBadge({ label: 'apps', message: 'no longer available' })
t.create('apps (valid, total)')
.get('/at/AFNetworking.json')
.expectJSON({ name: 'apps', value: 'no longer available' })
.expectBadge({ label: 'apps', message: 'no longer available' })
t.create('apps (not found)')
.get('/at/not-a-package.json')
.expectJSON({ name: 'apps', value: 'no longer available' })
.expectBadge({ label: 'apps', message: 'no longer available' })

View File

@@ -1,17 +1,14 @@
'use strict'
const Joi = require('joi')
const { isIntegerPercentage } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('doc percent (valid)')
.get('/AFNetworking.json')
.expectJSONTypes(
Joi.object().keys({
name: 'docs',
value: isIntegerPercentage,
})
)
.expectBadge({
label: 'docs',
message: isIntegerPercentage,
})
t.create('doc percent (null)')
.get('/AFNetworking.json')
@@ -20,8 +17,8 @@ t.create('doc percent (null)')
.get('/api/v1/pods/AFNetworking')
.reply(200, '{"cocoadocs": {"doc_percent": null}}')
)
.expectJSON({ name: 'docs', value: '0%' })
.expectBadge({ label: 'docs', message: '0%' })
t.create('doc percent (not found)')
.get('/not-a-package.json')
.expectJSON({ name: 'docs', value: 'not found' })
.expectBadge({ label: 'docs', message: 'not found' })

View File

@@ -10,16 +10,16 @@ const t = (module.exports = new ServiceTester({
t.create('downloads (valid, monthly)')
.get('/dm/AFNetworking.json')
.expectJSON({ name: 'downloads', value: 'no longer available' })
.expectBadge({ label: 'downloads', message: 'no longer available' })
t.create('downloads (valid, weekly)')
.get('/dw/AFNetworking.json')
.expectJSON({ name: 'downloads', value: 'no longer available' })
.expectBadge({ label: 'downloads', message: 'no longer available' })
t.create('downloads (valid, total)')
.get('/dt/AFNetworking.json')
.expectJSON({ name: 'downloads', value: 'no longer available' })
.expectBadge({ label: 'downloads', message: 'no longer available' })
t.create('downloads (not found)')
.get('/dt/not-a-package.json')
.expectJSON({ name: 'downloads', value: 'no longer available' })
.expectBadge({ label: 'downloads', message: 'no longer available' })

View File

@@ -4,8 +4,8 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('license (valid)')
.get('/AFNetworking.json')
.expectJSON({ name: 'license', value: 'MIT' })
.expectBadge({ label: 'license', message: 'MIT' })
t.create('license (not found)')
.get('/not-a-package.json')
.expectJSON({ name: 'license', value: 'not found' })
.expectBadge({ label: 'license', message: 'not found' })

View File

@@ -9,16 +9,14 @@ const isPlatform = Joi.string().regex(
t.create('platform (valid)')
.get('/AFNetworking.json')
.expectJSONTypes(
Joi.object().keys({
name: 'platform',
value: isPlatform,
})
)
.expectBadge({
label: 'platform',
message: isPlatform,
})
t.create('platform (not found)')
.get('/not-a-package.json')
.expectJSON({ name: 'platform', value: 'not found' })
.expectBadge({ label: 'platform', message: 'not found' })
t.create('platform (missing platforms key)')
.get('/AFNetworking.json')
@@ -27,4 +25,4 @@ t.create('platform (missing platforms key)')
.get('/api/v1/pods/AFNetworking/specs/latest')
.reply(200, { version: 'v1.0', license: 'MIT' })
)
.expectJSON({ name: 'platform', value: 'ios | osx' })
.expectBadge({ label: 'platform', message: 'ios | osx' })

View File

@@ -1,18 +1,15 @@
'use strict'
const Joi = require('joi')
const { isVPlusDottedVersionAtLeastOne } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('version (valid)')
.get('/AFNetworking.json')
.expectJSONTypes(
Joi.object().keys({
name: 'pod',
value: isVPlusDottedVersionAtLeastOne,
})
)
.expectBadge({
label: 'pod',
message: isVPlusDottedVersionAtLeastOne,
})
t.create('version (not found)')
.get('/not-a-package.json')
.expectJSON({ name: 'pod', value: 'not found' })
.expectBadge({ label: 'pod', message: 'not found' })

View File

@@ -1,37 +1,32 @@
'use strict'
const Joi = require('joi')
const { isIntegerPercentage } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('Coverage')
.get('/59d607d0e311408885e418004068ea58.json')
.expectJSONTypes(
Joi.object().keys({
name: 'coverage',
value: isIntegerPercentage,
})
)
.expectBadge({
label: 'coverage',
message: isIntegerPercentage,
})
t.create('Coverage on branch')
.get('/59d607d0e311408885e418004068ea58/master.json')
.expectJSONTypes(
Joi.object().keys({
name: 'coverage',
value: isIntegerPercentage,
})
)
.expectBadge({
label: 'coverage',
message: isIntegerPercentage,
})
t.create('Coverage not enabled')
.get('/e27821fb6289410b8f58338c7e0bc686.json')
.expectJSON({
name: 'coverage',
value: 'not enabled for this project',
.expectBadge({
label: 'coverage',
message: 'not enabled for this project',
})
t.create('Coverage (project not found)')
.get('/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.json')
.expectJSON({
name: 'coverage',
value: 'project not found',
.expectBadge({
label: 'coverage',
message: 'project not found',
})

View File

@@ -1,32 +1,27 @@
'use strict'
const Joi = require('joi')
const t = (module.exports = require('../tester').createServiceTester())
const { codacyGrade } = require('./codacy-helpers')
t.create('Code quality')
.get('/grade/e27821fb6289410b8f58338c7e0bc686.json')
.expectJSONTypes(
Joi.object().keys({
name: 'code quality',
value: codacyGrade,
})
)
.expectBadge({
label: 'code quality',
message: codacyGrade,
})
t.create('Code quality on branch')
.get('/grade/e27821fb6289410b8f58338c7e0bc686/master.json')
.expectJSONTypes(
Joi.object().keys({
name: 'code quality',
value: codacyGrade,
})
)
.expectBadge({
label: 'code quality',
message: codacyGrade,
})
t.create('Code quality (package not found)')
.get('/grade/00000000000000000000000000000000/master.json')
.expectJSON({
name: 'code quality',
value: 'project or branch not found',
.expectBadge({
label: 'code quality',
message: 'project or branch not found',
})
// This is a known bug. The badge endpoint for a nonexistent branch returns
@@ -37,7 +32,7 @@ t.create('Code quality (package not found)')
// https://api.codacy.com/project/badge/grade/e27821fb6289410b8f58338c7e0bc686?branch=foo
// t.create('Code quality on branch (branch not found)')
// .get('/grade/e27821fb6289410b8f58338c7e0bc686/not-a-branch.json')
// .expectJSON({
// name: 'code quality',
// value: 'project or branch not found',
// .expectBadge({
// label: 'code quality',
// message: 'project or branch not found',
// })

View File

@@ -12,105 +12,89 @@ const t = (module.exports = new ServiceTester({
// Tests based on Code Climate's test reports endpoint.
t.create('test coverage percentage')
.get('/c/jekyll/jekyll.json')
.expectJSONTypes(
Joi.object().keys({
name: 'coverage',
value: isIntegerPercentage,
})
)
.expectBadge({
label: 'coverage',
message: isIntegerPercentage,
})
t.create('test coverage percentage alternative coverage URL')
.get('/coverage/jekyll/jekyll.json')
.expectJSONTypes(
Joi.object().keys({
name: 'coverage',
value: isIntegerPercentage,
})
)
.expectBadge({
label: 'coverage',
message: isIntegerPercentage,
})
t.create('test coverage percentage alternative top-level URL')
.get('/jekyll/jekyll.json')
.expectJSONTypes(
Joi.object().keys({
name: 'coverage',
value: isIntegerPercentage,
})
)
.expectBadge({
label: 'coverage',
message: isIntegerPercentage,
})
t.create('test coverage letter')
.get('/c-letter/jekyll/jekyll.json')
.expectJSONTypes(
Joi.object().keys({
name: 'coverage',
value: Joi.equal('A', 'B', 'C', 'D', 'E', 'F'),
})
)
.expectBadge({
label: 'coverage',
message: Joi.equal('A', 'B', 'C', 'D', 'E', 'F'),
})
t.create('test coverage percentage for non-existent repo')
.get('/c/unknown/unknown.json')
.expectJSON({
name: 'coverage',
value: 'not found',
.expectBadge({
label: 'coverage',
message: 'not found',
})
t.create('test coverage percentage for repo without test reports')
.get('/c/angular/angular.js.json')
.expectJSON({
name: 'coverage',
value: 'unknown',
.expectBadge({
label: 'coverage',
message: 'unknown',
})
// Tests based on Code Climate's snapshots endpoint.
t.create('issues count')
.get('/issues/angular/angular.js.json')
.expectJSONTypes(
Joi.object().keys({
name: 'issues',
value: Joi.number()
.integer()
.positive(),
})
)
.expectBadge({
label: 'issues',
message: Joi.number()
.integer()
.positive(),
})
t.create('technical debt percentage')
.get('/tech-debt/angular/angular.js.json')
.expectJSONTypes(
Joi.object().keys({
name: 'technical debt',
value: isIntegerPercentage,
})
)
.expectBadge({
label: 'technical debt',
message: isIntegerPercentage,
})
t.create('maintainability percentage')
.get('/maintainability-percentage/angular/angular.js.json')
.expectJSONTypes(
Joi.object().keys({
name: 'maintainability',
value: isIntegerPercentage,
})
)
.expectBadge({
label: 'maintainability',
message: isIntegerPercentage,
})
t.create('maintainability letter')
.get('/maintainability/angular/angular.js.json')
.expectJSONTypes(
Joi.object().keys({
name: 'maintainability',
value: Joi.equal('A', 'B', 'C', 'D', 'E', 'F'),
})
)
.expectBadge({
label: 'maintainability',
message: Joi.equal('A', 'B', 'C', 'D', 'E', 'F'),
})
t.create('maintainability letter for non-existent repo')
.get('/maintainability/unknown/unknown.json')
.expectJSON({
name: 'maintainability',
value: 'not found',
.expectBadge({
label: 'maintainability',
message: 'not found',
})
t.create('maintainability letter for repo without snapshots')
.get('/maintainability/kabisaict/flow.json')
.expectJSON({
name: 'maintainability',
value: 'unknown',
.expectBadge({
label: 'maintainability',
message: 'unknown',
})
t.create('malformed response for outer user repos query')
@@ -122,9 +106,9 @@ t.create('malformed response for outer user repos query')
data: [{}], // No relationships in the list of data elements.
})
)
.expectJSON({
name: 'maintainability',
value: 'invalid',
.expectBadge({
label: 'maintainability',
message: 'invalid',
})
t.create('malformed response for inner specific repo query')
@@ -135,7 +119,7 @@ t.create('malformed response for inner specific repo query')
.reply(200, {})
) // No data.
.networkOn() // Combined with allowUnmocked: true, this allows the outer user repos query to go through.
.expectJSON({
name: 'maintainability',
value: 'invalid',
.expectBadge({
label: 'maintainability',
message: 'invalid',
})

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { ServiceTester } = require('../tester')
const { isIntegerPercentage } = require('../test-validators')
@@ -11,18 +10,14 @@ const t = (module.exports = new ServiceTester({
t.create('gets coverage status')
.get('/c/github/codecov/example-python.json')
.expectJSONTypes(
Joi.object().keys({
name: 'coverage',
value: isIntegerPercentage,
})
)
.expectBadge({
label: 'coverage',
message: isIntegerPercentage,
})
t.create('gets coverate status for branch')
.get('/c/github/codecov/example-python/master.json')
.expectJSONTypes(
Joi.object().keys({
name: 'coverage',
value: isIntegerPercentage,
})
)
.expectBadge({
label: 'coverage',
message: isIntegerPercentage,
})

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { isBuildStatus } = require('../build-status')
const { ServiceTester } = require('../tester')
@@ -11,34 +10,30 @@ const t = (module.exports = new ServiceTester({
t.create('codeship (valid, no branch)')
.get('/d6c1ddd0-16a3-0132-5f85-2e35c05e22b1.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: isBuildStatus,
})
)
.expectBadge({
label: 'build',
message: isBuildStatus,
})
t.create('codeship (valid, with branch)')
.get('/d6c1ddd0-16a3-0132-5f85-2e35c05e22b1/master.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: isBuildStatus,
})
)
.expectBadge({
label: 'build',
message: isBuildStatus,
})
t.create('codeship (repo not found)')
.get('/not-a-repo.json')
.expectJSON({ name: 'build', value: 'not found' })
.expectBadge({ label: 'build', message: 'not found' })
t.create('codeship (branch not found)')
.get('/d6c1ddd0-16a3-0132-5f85-2e35c05e22b1/not-a-branch.json')
.expectJSON({ name: 'build', value: 'branch not found' })
.expectBadge({ label: 'build', message: 'branch not found' })
t.create('codeship (connection error)')
.get('/d6c1ddd0-16a3-0132-5f85-2e35c05e22b1.json')
.networkOff()
.expectJSON({ name: 'build', value: 'inaccessible' })
.expectBadge({ label: 'build', message: 'inaccessible' })
t.create('codeship (unexpected response header)')
.get('/d6c1ddd0-16a3-0132-5f85-2e35c05e22b1.json')
@@ -49,7 +44,7 @@ t.create('codeship (unexpected response header)')
'content-disposition': 'foo',
})
)
.expectJSON({ name: 'build', value: 'unknown' })
.expectBadge({ label: 'build', message: 'unknown' })
t.create('codeship (unexpected response body)')
.get('/d6c1ddd0-16a3-0132-5f85-2e35c05e22b1.json')
@@ -58,4 +53,4 @@ t.create('codeship (unexpected response body)')
.get('/projects/d6c1ddd0-16a3-0132-5f85-2e35c05e22b1/status')
.reply(200, '')
)
.expectJSON({ name: 'build', value: 'invalid' })
.expectBadge({ label: 'build', message: 'invalid' })

View File

@@ -12,12 +12,10 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('Codetally')
.get('/triggerman722/colorstrap.json')
.expectJSONTypes(
Joi.object().keys({
name: 'codetally',
value: Joi.string().regex(/\b\d+(?:.\d+)?/),
})
)
.expectBadge({
label: 'codetally',
message: Joi.string().regex(/\b\d+(?:.\d+)?/),
})
t.create('Empty')
.get('/triggerman722/colorstrap.json')
@@ -31,9 +29,9 @@ t.create('Empty')
currency_abbreviation: 'CAD',
})
)
.expectJSON({ name: 'codetally', value: '$0.00' })
.expectBadge({ label: 'codetally', message: '$0.00' })
t.create('Non existent')
.get('/not/real.json')
.timeout(10000)
.expectJSON({ name: 'codetally', value: 'repo not found' })
.expectBadge({ label: 'codetally', message: 'repo not found' })

View File

@@ -10,57 +10,47 @@ const t = (module.exports = new ServiceTester({ id: 'conda', title: 'Conda' }))
t.create('version')
.get('/v/conda-forge/zlib.json')
.expectJSONTypes(
Joi.object().keys({
name: 'conda|conda-forge',
value: isVPlusTripleDottedVersion,
})
)
.expectBadge({
label: 'conda|conda-forge',
message: isVPlusTripleDottedVersion,
})
t.create('version (skip prefix)')
.get('/vn/conda-forge/zlib.json')
.expectJSONTypes(
Joi.object().keys({
name: 'conda-forge',
value: isVPlusTripleDottedVersion,
})
)
.expectBadge({
label: 'conda-forge',
message: isVPlusTripleDottedVersion,
})
t.create('platform')
.get('/p/conda-forge/zlib.json')
.expectJSONTypes(
Joi.object().keys({
name: 'conda|platform',
value: isCondaPlatform,
})
)
.expectBadge({
label: 'conda|platform',
message: isCondaPlatform,
})
t.create('platform (skip prefix)')
.get('/pn/conda-forge/zlib.json')
.expectJSONTypes(
Joi.object().keys({
name: 'platform',
value: isCondaPlatform,
})
)
.expectBadge({
label: 'platform',
message: isCondaPlatform,
})
t.create('downloads')
.get('/d/conda-forge/zlib.json')
.expectJSONTypes(
Joi.object().keys({
name: 'conda|downloads',
value: isMetric,
})
)
.expectBadge({
label: 'conda|downloads',
message: isMetric,
})
t.create('downloads (skip prefix)')
.get('/dn/conda-forge/zlib.json')
.expectJSONTypes(Joi.object().keys({ name: 'downloads', value: isMetric }))
.expectBadge({ label: 'downloads', message: isMetric })
t.create('unknown package')
.get('/d/conda-forge/some-bogus-package-that-never-exists.json')
.expectJSON({ name: 'conda', value: 'not found' })
.expectBadge({ label: 'conda', message: 'not found' })
t.create('unknown channel')
.get('/d/some-bogus-channel-that-never-exists/zlib.json')
.expectJSON({ name: 'conda', value: 'not found' })
.expectBadge({ label: 'conda', message: 'not found' })

View File

@@ -6,27 +6,23 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('build status on default branch')
.get('/git-hub/doctrine/dbal.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
})
)
.expectBadge({
label: 'build',
message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
})
t.create('build status on named branch')
.get('/git-hub/doctrine/dbal/develop.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
value: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
})
)
.expectBadge({
label: 'build',
message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
})
t.create('unknown repo')
.get('/git-hub/this-repo/does-not-exist.json')
.expectJSON({ name: 'build', value: 'invalid' })
.expectBadge({ label: 'build', message: 'invalid' })
t.create('connection error')
.get('/git-hub/doctrine/dbal.json')
.networkOff()
.expectJSON({ name: 'build', value: 'invalid' })
.expectBadge({ label: 'build', message: 'invalid' })

View File

@@ -1,17 +1,14 @@
'use strict'
const Joi = require('joi')
const { isVPlusDottedVersionAtLeastOne } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('version')
.get('/chef-sugar.json')
.expectJSONTypes(
Joi.object().keys({
name: 'cookbook',
value: isVPlusDottedVersionAtLeastOne,
})
)
.expectBadge({
label: 'cookbook',
message: isVPlusDottedVersionAtLeastOne,
})
t.create('version (mocked)')
.get('/chef-sugar.json?style=_shields_test')
@@ -22,12 +19,12 @@ t.create('version (mocked)')
version: '4.1.0',
})
)
.expectJSON({
name: 'cookbook',
value: 'v4.1.0',
.expectBadge({
label: 'cookbook',
message: 'v4.1.0',
color: 'blue',
})
t.create('version (not found)')
.get('/not-a-cookbook.json')
.expectJSON({ name: 'cookbook', value: 'not found' })
.expectBadge({ label: 'cookbook', message: 'not found' })

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { isIntegerPercentage } = require('../test-validators')
const { ServiceTester } = require('../tester')
@@ -16,7 +15,7 @@ t.create('error status code - location header is missing')
.head('/repos/github/not/existed/badge.svg')
.reply(404)
)
.expectJSON({ name: 'coverage', value: 'invalid' })
.expectBadge({ label: 'coverage', message: 'invalid' })
t.create('malformed location')
.get('/github/user/repository.json')
@@ -32,7 +31,7 @@ t.create('malformed location')
}
)
)
.expectJSON({ name: 'coverage', value: 'malformed' })
.expectBadge({ label: 'coverage', message: 'malformed' })
t.create('NaN percentage in location')
.get('/github/user/repository.json')
@@ -48,12 +47,12 @@ t.create('NaN percentage in location')
}
)
)
.expectJSON({ name: 'coverage', value: 'unknown' })
.expectBadge({ label: 'coverage', message: 'unknown' })
t.create('connection error')
.get('/github/user/repository.json')
.networkOff()
.expectJSON({ name: 'coverage', value: 'invalid' })
.expectBadge({ label: 'coverage', message: 'invalid' })
t.create('show coverage')
.get('/github/user/repository.json')
@@ -69,7 +68,7 @@ t.create('show coverage')
}
)
)
.expectJSON({ name: 'coverage', value: '50%' })
.expectBadge({ label: 'coverage', message: '50%' })
t.create('show coverage for legacy github link')
.get('/user/repository.json')
@@ -85,7 +84,7 @@ t.create('show coverage for legacy github link')
}
)
)
.expectJSON({ name: 'coverage', value: '50%' })
.expectBadge({ label: 'coverage', message: '50%' })
t.create('show coverage for branch')
.get('/github/user/repository/branch.json')
@@ -101,7 +100,7 @@ t.create('show coverage for branch')
}
)
)
.expectJSON({ name: 'coverage', value: '50%' })
.expectBadge({ label: 'coverage', message: '50%' })
t.create('show coverage for bitbucket')
.get('/bitbucket/user/repository.json')
@@ -117,7 +116,7 @@ t.create('show coverage for bitbucket')
}
)
)
.expectJSON({ name: 'coverage', value: '50%' })
.expectBadge({ label: 'coverage', message: '50%' })
t.create('show coverage for bitbucket with branch')
.get('/bitbucket/user/repository/branch.json')
@@ -133,22 +132,16 @@ t.create('show coverage for bitbucket with branch')
}
)
)
.expectJSON({ name: 'coverage', value: '50%' })
.expectBadge({ label: 'coverage', message: '50%' })
t.create('github coverage')
.get('/github/jekyll/jekyll.json')
.expectJSONTypes(
Joi.object().keys({ name: 'coverage', value: isIntegerPercentage })
)
.expectBadge({ label: 'coverage', message: isIntegerPercentage })
t.create('github coverage for legacy link')
.get('/jekyll/jekyll.json')
.expectJSONTypes(
Joi.object().keys({ name: 'coverage', value: isIntegerPercentage })
)
.expectBadge({ label: 'coverage', message: isIntegerPercentage })
t.create('bitbucket coverage')
.get('/bitbucket/pyKLIP/pyklip.json')
.expectJSONTypes(
Joi.object().keys({ name: 'coverage', value: isIntegerPercentage })
)
.expectBadge({ label: 'coverage', message: isIntegerPercentage })

View File

@@ -10,14 +10,14 @@ const t = (module.exports = new ServiceTester({
t.create('no longer available (streams)')
.get('/streams/44b25sjc9l3ntc2ngfi29tngro.json')
.expectJSON({
name: 'coverity',
value: 'no longer available',
.expectBadge({
label: 'coverity',
message: 'no longer available',
})
t.create('no longer available (jobs)')
.get('/jobs/p4tmm8031t4i971r0im4s7lckk.json')
.expectJSON({
name: 'coverity',
value: 'no longer available',
.expectBadge({
label: 'coverity',
message: 'no longer available',
})

View File

@@ -5,17 +5,15 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('live: known project id')
.get('/3997.json')
.expectJSONTypes(
Joi.object().keys({
name: 'coverity',
value: Joi.string().regex(/passing|passed .* new defects|pending|failed/),
})
)
.expectBadge({
label: 'coverity',
message: Joi.string().regex(/passing|passed .* new defects|pending|failed/),
})
t.create('live: unknown project id')
.get('/abc.json')
// Coverity actually returns an HTTP 200 status with an HTML page when the project is not found.
.expectJSON({ name: 'coverity', value: 'unparseable json response' })
.expectBadge({ label: 'coverity', message: 'unparseable json response' })
t.create('404 response')
.get('/1.json')
@@ -24,7 +22,7 @@ t.create('404 response')
.get('/badge.json')
.reply(404)
)
.expectJSON({ name: 'coverity', value: 'project not found' })
.expectBadge({ label: 'coverity', message: 'project not found' })
t.create('passed')
.get('/2.json?style=_shields_test')
@@ -35,9 +33,9 @@ t.create('passed')
message: 'passed',
})
)
.expectJSON({
name: 'coverity',
value: 'passing',
.expectBadge({
label: 'coverity',
message: 'passing',
color: 'brightgreen',
})
@@ -50,9 +48,9 @@ t.create('passed with defects')
message: 'passed 51 new defects',
})
)
.expectJSON({
name: 'coverity',
value: 'passed 51 new defects',
.expectBadge({
label: 'coverity',
message: 'passed 51 new defects',
color: 'yellow',
})
@@ -65,9 +63,9 @@ t.create('pending')
message: 'pending',
})
)
.expectJSON({
name: 'coverity',
value: 'pending',
.expectBadge({
label: 'coverity',
message: 'pending',
color: 'orange',
})
@@ -80,8 +78,8 @@ t.create('failed')
message: 'failed',
})
)
.expectJSON({
name: 'coverity',
value: 'failed',
.expectBadge({
label: 'coverity',
message: 'failed',
color: 'red',
})

View File

@@ -4,14 +4,14 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('license (valid)')
.get('/Config-Augeas.json')
.expectJSON({
name: 'license',
value: 'lgpl_2_1',
.expectBadge({
label: 'license',
message: 'lgpl_2_1',
})
t.create('license (not found)')
.get('/not-a-package.json')
.expectJSON({
name: 'cpan',
value: 'not found',
.expectBadge({
label: 'cpan',
message: 'not found',
})

View File

@@ -5,14 +5,14 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('version (valid)')
.get('/Config-Augeas.json')
.expectJSONTypes({
name: 'cpan',
value: isVPlusDottedVersionAtLeastOne,
.expectBadge({
label: 'cpan',
message: isVPlusDottedVersionAtLeastOne,
})
t.create('version (not found)')
.get('/not-a-package.json')
.expectJSON({
name: 'cpan',
value: 'not found',
.expectBadge({
label: 'cpan',
message: 'not found',
})

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { ServiceTester } = require('../tester')
const { isVPlusTripleDottedVersion } = require('../test-validators')
@@ -11,21 +10,19 @@ const t = (module.exports = new ServiceTester({
t.create('version (valid)')
.get('/v/devtools.json')
.expectJSONTypes(
Joi.object().keys({
name: 'cran',
value: isVPlusTripleDottedVersion,
})
)
.expectBadge({
label: 'cran',
message: isVPlusTripleDottedVersion,
})
t.create('version (not found)')
.get('/v/some-bogus-package.json')
.expectJSON({ name: 'cran', value: 'not found' })
.expectBadge({ label: 'cran', message: 'not found' })
t.create('license (valid)')
.get('/l/devtools.json')
.expectJSON({ name: 'license', value: 'GPL (>= 2)' })
.expectBadge({ label: 'license', message: 'GPL (>= 2)' })
t.create('license (not found)')
.get('/l/some-bogus-package.json')
.expectJSON({ name: 'cran', value: 'not found' })
.expectBadge({ label: 'cran', message: 'not found' })

View File

@@ -11,33 +11,33 @@ const t = (module.exports = new ServiceTester({
t.create('total downloads')
.get('/d/libc.json')
.expectJSONTypes({ name: 'downloads', value: isMetric })
.expectBadge({ label: 'downloads', message: isMetric })
t.create('total downloads (with version)')
.get('/d/libc/0.2.31.json')
.expectJSONTypes({
name: 'downloads@0.2.31',
value: isMetric,
.expectBadge({
label: 'downloads@0.2.31',
message: isMetric,
})
t.create('downloads for version')
.get('/dv/libc.json')
.expectJSONTypes({
name: 'downloads@latest',
value: isMetric,
.expectBadge({
label: 'downloads@latest',
message: isMetric,
})
t.create('downloads for version (with version)')
.get('/dv/libc/0.2.31.json')
.expectJSONTypes({
name: 'downloads@0.2.31',
value: isMetric,
.expectBadge({
label: 'downloads@0.2.31',
message: isMetric,
})
t.create('downloads (invalid version)')
.get('/d/libc/7.json')
.expectJSON({ name: 'crates.io', value: 'invalid semver: 7' })
.expectBadge({ label: 'crates.io', message: 'invalid semver: 7' })
t.create('downloads (not found)')
.get('/d/not-a-real-package.json')
.expectJSON({ name: 'crates.io', value: 'not found' })
.expectBadge({ label: 'crates.io', message: 'not found' })

View File

@@ -10,12 +10,12 @@ const t = (module.exports = new ServiceTester({
t.create('license')
.get('/libc.json')
.expectJSON({ name: 'license', value: 'MIT OR Apache-2.0' })
.expectBadge({ label: 'license', message: 'MIT OR Apache-2.0' })
t.create('license (with version)')
.get('/libc/0.2.44.json')
.expectJSON({ name: 'license', value: 'MIT OR Apache-2.0' })
.expectBadge({ label: 'license', message: 'MIT OR Apache-2.0' })
t.create('license (not found)')
.get('/not-a-real-package.json')
.expectJSON({ name: 'crates.io', value: 'not found' })
.expectBadge({ label: 'crates.io', message: 'not found' })

View File

@@ -11,8 +11,8 @@ const t = (module.exports = new ServiceTester({
t.create('version')
.get('/libc.json')
.expectJSONTypes({ name: 'crates.io', value: isSemver })
.expectBadge({ label: 'crates.io', message: isSemver })
t.create('version (not found)')
.get('/not-a-real-package.json')
.expectJSON({ name: 'crates.io', value: 'not found' })
.expectBadge({ label: 'crates.io', message: 'not found' })

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { ServiceTester } = require('../tester')
const { isVPlusDottedVersionAtLeastOne } = require('../test-validators')
@@ -11,9 +10,9 @@ const t = (module.exports = new ServiceTester({
t.create('license')
.get('/l/novel.json')
.expectJSON({
name: 'license',
value: 'lppl1.3c, ofl',
.expectBadge({
label: 'license',
message: 'lppl1.3c, ofl',
})
t.create('license missing')
@@ -27,9 +26,9 @@ t.create('license missing')
},
})
)
.expectJSON({
name: 'license',
value: 'missing',
.expectBadge({
label: 'license',
message: 'missing',
})
t.create('single license')
@@ -44,19 +43,17 @@ t.create('single license')
},
})
)
.expectJSON({
name: 'license',
value: 'knuth',
.expectBadge({
label: 'license',
message: 'knuth',
})
t.create('version')
.get('/v/novel.json')
.expectJSONTypes(
Joi.object().keys({
name: 'ctan',
value: isVPlusDottedVersionAtLeastOne,
})
)
.expectBadge({
label: 'ctan',
message: isVPlusDottedVersionAtLeastOne,
})
t.create('version (mocked)')
.get('/v/novel.json?style=_shields_test')
@@ -69,8 +66,8 @@ t.create('version (mocked)')
},
})
)
.expectJSON({
name: 'ctan',
value: 'v1.11',
.expectBadge({
label: 'ctan',
message: 'v1.11',
color: 'blue',
})

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { ServiceTester } = require('../tester')
const { isRelativeFormattedDate } = require('../test-validators')
@@ -11,10 +10,8 @@ const t = (module.exports = new ServiceTester({
t.create('Relative date')
.get('/1540814400.json')
.expectJSONTypes(
Joi.object().keys({ name: 'date', value: isRelativeFormattedDate })
)
.expectBadge({ label: 'date', message: isRelativeFormattedDate })
t.create('Relative date - Invalid')
.get('/9999999999999.json')
.expectJSONTypes(Joi.object().keys({ name: 'date', value: 'invalid date' }))
.expectBadge({ label: 'date', message: 'invalid date' })

View File

@@ -14,65 +14,55 @@ const t = (module.exports = new ServiceTester({ id: 'david', title: 'David' }))
t.create('david dependencies (valid)')
.get('/expressjs/express.json')
.expectJSONTypes(
Joi.object().keys({
name: 'dependencies',
value: isDependencyStatus,
})
)
.expectBadge({
label: 'dependencies',
message: isDependencyStatus,
})
t.create('david dev dependencies (valid)')
.get('/dev/expressjs/express.json')
.expectJSONTypes(
Joi.object().keys({
name: 'dev dependencies',
value: isDependencyStatus,
})
)
.expectBadge({
label: 'dev dependencies',
message: isDependencyStatus,
})
t.create('david optional dependencies (valid)')
.get('/optional/elnounch/byebye.json')
.expectJSONTypes(
Joi.object().keys({
name: 'optional dependencies',
value: isDependencyStatus,
})
)
.expectBadge({
label: 'optional dependencies',
message: isDependencyStatus,
})
t.create('david peer dependencies (valid)')
.get('/peer/webcomponents/generator-element.json')
.expectJSONTypes(
Joi.object().keys({
name: 'peer dependencies',
value: isDependencyStatus,
})
)
.expectBadge({
label: 'peer dependencies',
message: isDependencyStatus,
})
t.create('david dependencies with path (valid)')
.get('/babel/babel.json?path=packages/babel-core')
.expectJSONTypes(
Joi.object().keys({
name: 'dependencies',
value: isDependencyStatus,
})
)
.expectBadge({
label: 'dependencies',
message: isDependencyStatus,
})
t.create('david dependencies (none)')
.get('/peer/expressjs/express.json') // express does not specify peer dependencies
.expectJSON({ name: 'peer dependencies', value: 'none' })
.expectBadge({ label: 'peer dependencies', message: 'none' })
t.create('david dependencies (repo not found)')
.get('/pyvesb/emptyrepo.json')
.expectJSON({ name: 'dependencies', value: 'invalid' })
.expectBadge({ label: 'dependencies', message: 'invalid' })
t.create('david dependencies (path not found')
.get('/babel/babel.json?path=invalid/path')
.expectJSON({ name: 'dependencies', value: 'invalid' })
.expectBadge({ label: 'dependencies', message: 'invalid' })
t.create('david dependencies (connection error)')
.get('/expressjs/express.json')
.networkOff()
.expectJSON({ name: 'dependencies', value: 'inaccessible' })
.expectBadge({ label: 'dependencies', message: 'inaccessible' })
t.create('david dependencies (unexpected response)')
.get('/expressjs/express.json')
@@ -81,4 +71,4 @@ t.create('david dependencies (unexpected response)')
.get('/expressjs/express/info.json')
.reply(invalidJSON)
)
.expectJSON({ name: 'dependencies', value: 'invalid' })
.expectBadge({ label: 'dependencies', message: 'invalid' })

View File

@@ -5,12 +5,12 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('start time')
.get('/starttime.json')
.expectJSONTypes({ name: 'start time', value: Joi.date().required() })
.expectBadge({ label: 'start time', message: Joi.date().required() })
t.create('Flip: first request')
.get('/flip.json')
.expectJSON({ name: 'flip', value: 'on' })
.expectBadge({ label: 'flip', message: 'on' })
t.create('Flip: second request')
.get('/flip.json')
.expectJSON({ name: 'flip', value: 'off' })
.expectBadge({ label: 'flip', message: 'off' })

View File

@@ -1,31 +1,26 @@
'use strict'
const Joi = require('joi')
const { isIntegerPercentage } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('semver stability (valid)')
.get('/bundler/puma.json')
.expectJSONTypes(
Joi.object().keys({
name: 'semver stability',
value: isIntegerPercentage,
link:
'https://dependabot.com/compatibility-score.html?dependency-name=puma&package-manager=bundler&version-scheme=semver',
})
)
.expectBadge({
label: 'semver stability',
message: isIntegerPercentage,
})
t.create('semver stability (invalid error)')
.get('/invalid-manager/puma.json?style=_shields_test')
.expectJSON({
name: 'semver stability',
value: 'invalid',
.expectBadge({
label: 'semver stability',
message: 'invalid',
color: 'lightgrey',
})
t.create('semver stability (missing dependency)')
.get('/bundler/some-random-missing-dependency.json')
.expectJSON({
name: 'semver stability',
value: 'unknown',
.expectBadge({
label: 'semver stability',
message: 'unknown',
})

View File

@@ -14,13 +14,11 @@ const t = (module.exports = new ServiceTester({ id: 'depfu', title: 'Depfu' }))
t.create('depfu dependencies (valid)')
.get('/depfu/example-ruby.json')
.expectJSONTypes(
Joi.object().keys({
name: 'dependencies',
value: isDependencyStatus,
})
)
.expectBadge({
label: 'dependencies',
message: isDependencyStatus,
})
t.create('depfu dependencies (repo not found)')
.get('/pyvesb/emptyrepo.json')
.expectJSON({ name: 'dependencies', value: 'not found' })
.expectBadge({ label: 'dependencies', message: 'not found' })

View File

@@ -5,17 +5,15 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('gets status for Reactiflux')
.get('/102860784329052160.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'chat',
value: Joi.string().regex(/^[0-9]+ online$/),
color: 'brightgreen',
})
)
.expectBadge({
label: 'chat',
message: Joi.string().regex(/^[0-9]+ online$/),
color: 'brightgreen',
})
t.create('invalid server ID')
.get('/12345.json')
.expectJSON({ name: 'chat', value: 'invalid server' })
.expectBadge({ label: 'chat', message: 'invalid server' })
t.create('widget disabled')
.get('/12345.json')
@@ -27,7 +25,7 @@ t.create('widget disabled')
message: 'Widget Disabled',
})
)
.expectJSON({ name: 'chat', value: 'widget disabled' })
.expectBadge({ label: 'chat', message: 'widget disabled' })
t.create('server error')
.get('/12345.json')
@@ -36,4 +34,4 @@ t.create('server error')
.get('/api/guilds/12345/widget.json')
.reply(500, 'Something broke')
)
.expectJSON({ name: 'chat', value: 'inaccessible' })
.expectBadge({ label: 'chat', message: 'inaccessible' })

View File

@@ -32,7 +32,7 @@ t.create('Topics')
.get('/site/statistics.json')
.reply(200, data)
)
.expectJSON({ name: 'discourse', value: '23k topics' })
.expectBadge({ label: 'discourse', message: '23k topics' })
t.create('Posts')
.get('/https/meta.discourse.org/posts.json')
@@ -41,7 +41,7 @@ t.create('Posts')
.get('/site/statistics.json')
.reply(200, data)
)
.expectJSON({ name: 'discourse', value: '338k posts' })
.expectBadge({ label: 'discourse', message: '338k posts' })
t.create('Users')
.get('/https/meta.discourse.org/users.json')
@@ -50,7 +50,7 @@ t.create('Users')
.get('/site/statistics.json')
.reply(200, data)
)
.expectJSON({ name: 'discourse', value: '31k users' })
.expectBadge({ label: 'discourse', message: '31k users' })
t.create('Likes')
.get('/https/meta.discourse.org/likes.json')
@@ -59,7 +59,7 @@ t.create('Likes')
.get('/site/statistics.json')
.reply(200, data)
)
.expectJSON({ name: 'discourse', value: '309k likes' })
.expectBadge({ label: 'discourse', message: '309k likes' })
t.create('Status')
.get('/https/meta.discourse.org/status.json')
@@ -68,7 +68,7 @@ t.create('Status')
.get('/site/statistics.json')
.reply(200, data)
)
.expectJSON({ name: 'discourse', value: 'online' })
.expectBadge({ label: 'discourse', message: 'online' })
t.create('Status with http (not https)')
.get('/http/meta.discourse.org/status.json')
@@ -77,12 +77,12 @@ t.create('Status with http (not https)')
.get('/site/statistics.json')
.reply(200, data)
)
.expectJSON({ name: 'discourse', value: 'online' })
.expectBadge({ label: 'discourse', message: 'online' })
t.create('Status (offline)')
.get('/https/meta.discourse.org/status.json')
.networkOff()
.expectJSON({ name: 'discourse', value: 'inaccessible' })
.expectBadge({ label: 'discourse', message: 'inaccessible' })
t.create('Invalid Host')
.get('/https/some.host/status.json')
@@ -91,44 +91,36 @@ t.create('Invalid Host')
.get('/site/statistics.json')
.reply(404, '<h1>Not Found</h1>')
)
.expectJSON({ name: 'discourse', value: 'not found' })
.expectBadge({ label: 'discourse', message: 'not found' })
t.create('Topics (live)')
.get('/https/meta.discourse.org/topics.json')
.expectJSONTypes(
Joi.object().keys({
name: 'discourse',
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? topics$/),
})
)
.expectBadge({
label: 'discourse',
message: Joi.string().regex(/^[0-9]+[kMGTPEZY]? topics$/),
})
t.create('Posts (live)')
.get('/https/meta.discourse.org/posts.json')
.expectJSONTypes(
Joi.object().keys({
name: 'discourse',
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? posts$/),
})
)
.expectBadge({
label: 'discourse',
message: Joi.string().regex(/^[0-9]+[kMGTPEZY]? posts$/),
})
t.create('Users (live)')
.get('/https/meta.discourse.org/users.json')
.expectJSONTypes(
Joi.object().keys({
name: 'discourse',
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? users$/),
})
)
.expectBadge({
label: 'discourse',
message: Joi.string().regex(/^[0-9]+[kMGTPEZY]? users$/),
})
t.create('Likes (live)')
.get('/https/meta.discourse.org/likes.json')
.expectJSONTypes(
Joi.object().keys({
name: 'discourse',
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? likes$/),
})
)
.expectBadge({
label: 'discourse',
message: Joi.string().regex(/^[0-9]+[kMGTPEZY]? likes$/),
})
t.create('Status (live)')
.get('/https/meta.discourse.org/status.json')
.expectJSON({ name: 'discourse', value: 'online' })
.expectBadge({ label: 'discourse', message: 'online' })

View File

@@ -9,14 +9,14 @@ const t = (module.exports = new ServiceTester({
t.create('no longer available (previously image size)')
.get('/image-size/_/ubuntu/latest.json')
.expectJSON({
name: 'dockbit',
value: 'no longer available',
.expectBadge({
label: 'dockbit',
message: 'no longer available',
})
t.create('no longer available (previously number of layers)')
.get('/layers/_/ubuntu/latest.json')
.expectJSON({
name: 'dockbit',
value: 'no longer available',
.expectBadge({
label: 'dockbit',
message: 'no longer available',
})

View File

@@ -8,25 +8,21 @@ const isAutomatedBuildStatus = Joi.string().valid('automated', 'manual')
t.create('docker automated build (valid, library)')
.get('/_/ubuntu.json')
.expectJSONTypes(
Joi.object().keys({
name: 'docker build',
value: isAutomatedBuildStatus,
})
)
.expectBadge({
label: 'docker build',
message: isAutomatedBuildStatus,
})
t.create('docker automated build (valid, user)')
.get('/jrottenberg/ffmpeg.json')
.expectJSONTypes(
Joi.object().keys({
name: 'docker build',
value: isAutomatedBuildStatus,
})
)
.expectBadge({
label: 'docker build',
message: isAutomatedBuildStatus,
})
t.create('docker automated build (not found)')
.get('/_/not-a-real-repo.json')
.expectJSON({ name: 'docker build', value: 'repo not found' })
.expectBadge({ label: 'docker build', message: 'repo not found' })
t.create('docker automated build - automated')
.get('/_/ubuntu.json?style=_shields_test')
@@ -35,9 +31,9 @@ t.create('docker automated build - automated')
.get('/v2/repositories/library/ubuntu')
.reply(200, { is_automated: true })
)
.expectJSON({
name: 'docker build',
value: 'automated',
.expectBadge({
label: 'docker build',
message: 'automated',
color: `#${dockerBlue}`,
})
@@ -48,4 +44,4 @@ t.create('docker automated build - manual')
.get('/v2/repositories/library/ubuntu')
.reply(200, { is_automated: false })
)
.expectJSON({ name: 'docker build', value: 'manual', color: 'yellow' })
.expectBadge({ label: 'docker build', message: 'manual', color: 'yellow' })

View File

@@ -1,22 +1,19 @@
'use strict'
const Joi = require('joi')
const { isBuildStatus } = require('../build-status')
const t = (module.exports = require('../tester').createServiceTester())
const { dockerBlue } = require('./docker-helpers')
t.create('docker build status (valid, user)')
.get('/jrottenberg/ffmpeg.json')
.expectJSONTypes(
Joi.object().keys({
name: 'docker build',
value: isBuildStatus,
})
)
.expectBadge({
label: 'docker build',
message: isBuildStatus,
})
t.create('docker build status (not found)')
.get('/_/not-a-real-repo.json')
.expectJSON({ name: 'docker build', value: 'repo not found' })
.expectBadge({ label: 'docker build', message: 'repo not found' })
t.create('docker build status (passing)')
.get('/_/ubuntu.json?style=_shields_test')
@@ -25,9 +22,9 @@ t.create('docker build status (passing)')
.get('/v2/repositories/library/ubuntu/buildhistory')
.reply(200, { results: [{ status: 10 }] })
)
.expectJSON({
name: 'docker build',
value: 'passing',
.expectBadge({
label: 'docker build',
message: 'passing',
color: 'brightgreen',
})
@@ -38,7 +35,7 @@ t.create('docker build status (failing)')
.get('/v2/repositories/library/ubuntu/buildhistory')
.reply(200, { results: [{ status: -1 }] })
)
.expectJSON({ name: 'docker build', value: 'failing', color: 'red' })
.expectBadge({ label: 'docker build', message: 'failing', color: 'red' })
t.create('docker build status (building)')
.get('/_/ubuntu.json?style=_shields_test')
@@ -47,8 +44,8 @@ t.create('docker build status (building)')
.get('/v2/repositories/library/ubuntu/buildhistory')
.reply(200, { results: [{ status: 1 }] })
)
.expectJSON({
name: 'docker build',
value: 'building',
.expectBadge({
label: 'docker build',
message: 'building',
color: `#${dockerBlue}`,
})

View File

@@ -1,29 +1,24 @@
'use strict'
const Joi = require('joi')
const { isMetric } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
const { dockerBlue } = require('./docker-helpers')
t.create('docker pulls (valid, library)')
.get('/_/ubuntu.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'docker pulls',
value: isMetric,
color: `#${dockerBlue}`,
})
)
.expectBadge({
label: 'docker pulls',
message: isMetric,
color: `#${dockerBlue}`,
})
t.create('docker pulls (valid, user)')
.get('/jrottenberg/ffmpeg.json')
.expectJSONTypes(
Joi.object().keys({
name: 'docker pulls',
value: isMetric,
})
)
.expectBadge({
label: 'docker pulls',
message: isMetric,
})
t.create('docker pulls (not found)')
.get('/_/not-a-real-repo.json')
.expectJSON({ name: 'docker pulls', value: 'repo not found' })
.expectBadge({ label: 'docker pulls', message: 'repo not found' })

View File

@@ -1,29 +1,24 @@
'use strict'
const Joi = require('joi')
const { isMetric } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
const { dockerBlue } = require('./docker-helpers')
t.create('docker stars (valid, library)')
.get('/_/ubuntu.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'docker stars',
value: isMetric,
color: `#${dockerBlue}`,
})
)
.expectBadge({
label: 'docker stars',
message: isMetric,
color: `#${dockerBlue}`,
})
t.create('docker stars (valid, user)')
.get('/jrottenberg/ffmpeg.json')
.expectJSONTypes(
Joi.object().keys({
name: 'docker stars',
value: isMetric,
})
)
.expectBadge({
label: 'docker stars',
message: isMetric,
})
t.create('docker stars (not found)')
.get('/_/not-a-real-repo.json')
.expectJSON({ name: 'docker stars', value: 'repo not found' })
.expectBadge({ label: 'docker stars', message: 'repo not found' })

View File

@@ -9,7 +9,7 @@ const t = (module.exports = new ServiceTester({
t.create('no longer available (previously get package status)')
.get('/gh/jaredcnance/dotnet-status/API.json')
.expectJSON({
name: 'dotnet status',
value: 'no longer available',
.expectBadge({
label: 'dotnet status',
message: 'no longer available',
})

View File

@@ -19,65 +19,53 @@ const t = (module.exports = new ServiceTester({
t.create('total downloads (valid)')
.get('/dt/vibe-d.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: isMetric,
color: isDownloadsColor,
})
)
.expectBadge({
label: 'downloads',
message: isMetric,
color: isDownloadsColor,
})
t.create('total downloads, specific version (valid)')
.get('/dt/vibe-d/0.8.4.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads@0.8.4',
value: Joi.string().regex(/^[1-9][0-9]*[kMGTPEZY]?$/),
color: isDownloadsColor,
})
)
.expectBadge({
label: 'downloads@0.8.4',
message: Joi.string().regex(/^[1-9][0-9]*[kMGTPEZY]?$/),
color: isDownloadsColor,
})
.timeout(15000)
t.create('total downloads, latest version (valid)')
.get('/dt/vibe-d/latest.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads@latest',
value: Joi.string().regex(/^[1-9][0-9]*[kMGTPEZY]?$/),
color: isDownloadsColor,
})
)
.expectBadge({
label: 'downloads@latest',
message: Joi.string().regex(/^[1-9][0-9]*[kMGTPEZY]?$/),
color: isDownloadsColor,
})
t.create('daily downloads (valid)')
.get('/dd/vibe-d.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: isMetricOverTimePeriod,
color: isDownloadsColor,
})
)
.expectBadge({
label: 'downloads',
message: isMetricOverTimePeriod,
color: isDownloadsColor,
})
t.create('weekly downloads (valid)')
.get('/dw/vibe-d.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: isMetricOverTimePeriod,
color: isDownloadsColor,
})
)
.expectBadge({
label: 'downloads',
message: isMetricOverTimePeriod,
color: isDownloadsColor,
})
t.create('monthly downloads (valid)')
.get('/dm/vibe-d.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: isMetricOverTimePeriod,
color: isDownloadsColor,
})
)
.expectBadge({
label: 'downloads',
message: isMetricOverTimePeriod,
color: isDownloadsColor,
})
t.create('total downloads (not found)')
.get('/dt/not-a-package.json')
.expectJSON({ name: 'downloads', value: 'not found' })
.expectBadge({ label: 'downloads', message: 'not found' })

View File

@@ -4,8 +4,8 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('license (valid)')
.get('/vibe-d.json')
.expectJSON({ name: 'license', value: 'MIT' })
.expectBadge({ label: 'license', message: 'MIT' })
t.create('license (not found)')
.get('/not-a-package.json')
.expectJSON({ name: 'license', value: 'not found' })
.expectBadge({ label: 'license', message: 'not found' })

View File

@@ -8,14 +8,12 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('version (valid)')
.get('/vibe-d.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'dub',
value: isVPlusDottedVersionNClausesWithOptionalSuffix,
color: Joi.equal('blue', 'orange'),
})
)
.expectBadge({
label: 'dub',
message: isVPlusDottedVersionNClausesWithOptionalSuffix,
color: Joi.equal('blue', 'orange'),
})
t.create('version (not found)')
.get('/not-a-package.json')
.expectJSON({ name: 'dub', value: 'not found' })
.expectBadge({ label: 'dub', message: 'not found' })

View File

@@ -6,9 +6,9 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('No URL specified')
.get('.json?query=$.name&label=Package Name&style=_shields_test')
.expectJSON({
name: 'Package Name',
value: 'invalid query parameter: url',
.expectBadge({
label: 'Package Name',
message: 'invalid query parameter: url',
color: 'red',
})
@@ -16,9 +16,9 @@ t.create('No query specified')
.get(
'.json?url=https://github.com/badges/shields/raw/master/package.json&label=Package Name&style=_shields_test'
)
.expectJSON({
name: 'Package Name',
value: 'invalid query parameter: query',
.expectBadge({
label: 'Package Name',
message: 'invalid query parameter: query',
color: 'red',
})
@@ -26,9 +26,9 @@ t.create('Malformed url')
.get(
'.json?url=https://github.com/badges/shields/raw/master/%0package.json&query=$.name&label=Package Name&style=_shields_test'
)
.expectJSON({
name: 'Package Name',
value: 'invalid',
.expectBadge({
label: 'Package Name',
message: 'invalid',
color: 'lightgrey',
})
@@ -36,9 +36,9 @@ t.create('JSON from url')
.get(
'.json?url=https://github.com/badges/shields/raw/master/package.json&query=$.name&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'shields.io',
.expectBadge({
label: 'custom badge',
message: 'shields.io',
color: 'blue',
})
@@ -46,9 +46,9 @@ t.create('JSON from uri (support uri query parameter)')
.get(
'.json?uri=https://github.com/badges/shields/raw/master/package.json&query=$.name&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'shields.io',
.expectBadge({
label: 'custom badge',
message: 'shields.io',
color: 'blue',
})
@@ -56,37 +56,33 @@ t.create('JSON from url | multiple results')
.get(
'.json?url=https://github.com/badges/shields/raw/master/package.json&query=$..keywords[0:2:1]'
)
.expectJSON({ name: 'custom badge', value: 'GitHub, badge' })
.expectBadge({ label: 'custom badge', message: 'GitHub, badge' })
t.create('JSON from url | caching with new query params')
.get(
'.json?url=https://github.com/badges/shields/raw/master/package.json&query=$.version'
)
.expectJSONTypes(
Joi.object().keys({
name: 'custom badge',
value: Joi.string().regex(/^\d+(\.\d+)?(\.\d+)?$/),
})
)
.expectBadge({
label: 'custom badge',
message: Joi.string().regex(/^\d+(\.\d+)?(\.\d+)?$/),
})
t.create('JSON from url | with prefix & suffix & label')
.get(
'.json?url=https://github.com/badges/shields/raw/master/package.json&query=$.version&prefix=v&suffix= dev&label=Shields'
)
.expectJSONTypes(
Joi.object().keys({
name: 'Shields',
value: Joi.string().regex(/^v\d+(\.\d+)?(\.\d+)?\sdev$/),
})
)
.expectBadge({
label: 'Shields',
message: Joi.string().regex(/^v\d+(\.\d+)?(\.\d+)?\sdev$/),
})
t.create('JSON from url | object doesnt exist')
.get(
'.json?url=https://github.com/badges/shields/raw/master/package.json&query=$.does_not_exist&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'no result',
.expectBadge({
label: 'custom badge',
message: 'no result',
color: 'lightgrey',
})
@@ -94,9 +90,9 @@ t.create('JSON from url | invalid url')
.get(
'.json?url=https://github.com/badges/shields/raw/master/notafile.json&query=$.version&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'resource not found',
.expectBadge({
label: 'custom badge',
message: 'resource not found',
color: 'red',
})
@@ -104,23 +100,27 @@ t.create('JSON from url | user color overrides default')
.get(
'.json?url=https://github.com/badges/shields/raw/master/package.json&query=$.name&color=10ADED&style=_shields_test'
)
.expectJSON({ name: 'custom badge', value: 'shields.io', color: '#10aded' })
.expectBadge({
label: 'custom badge',
message: 'shields.io',
color: '#10aded',
})
t.create('JSON from url | error color overrides default')
.get(
'.json?url=https://github.com/badges/shields/raw/master/notafile.json&query=$.version&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'resource not found',
.expectBadge({
label: 'custom badge',
message: 'resource not found',
color: 'red',
})
t.create('JSON from url | error color overrides user specified')
.get('.json?query=$.version&color=10ADED&style=_shields_test')
.expectJSON({
name: 'custom badge',
value: 'invalid query parameter: url',
.expectBadge({
label: 'custom badge',
message: 'invalid query parameter: url',
color: 'red',
})
@@ -135,7 +135,7 @@ t.create('JSON from url | request should set Accept header')
return '{"name":"test"}'
})
)
.expectJSON({ name: 'custom badge', value: 'test' })
.expectBadge({ label: 'custom badge', message: 'test' })
.after(() => {
expect(headers).to.have.property('accept', 'application/json')
})

View File

@@ -7,9 +7,9 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('No URL specified')
.get('.json?query=//name&label=Package Name&style=_shields_test')
.expectJSON({
name: 'Package Name',
value: 'invalid query parameter: url',
.expectBadge({
label: 'Package Name',
message: 'invalid query parameter: url',
color: 'red',
})
@@ -17,9 +17,9 @@ t.create('No query specified')
.get(
'.json?url=https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/707078&label=Package Name&style=_shields_test'
)
.expectJSON({
name: 'Package Name',
value: 'invalid query parameter: query',
.expectBadge({
label: 'Package Name',
message: 'invalid query parameter: query',
color: 'red',
})
@@ -27,9 +27,9 @@ t.create('XML from url')
.get(
'.json?url=https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/707078&query=/addon/name&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'IndieGala Helper',
.expectBadge({
label: 'custom badge',
message: 'IndieGala Helper',
color: 'blue',
})
@@ -37,9 +37,9 @@ t.create('XML from uri (support uri query parameter)')
.get(
'.json?uri=https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/707078&query=/addon/name&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'IndieGala Helper',
.expectBadge({
label: 'custom badge',
message: 'IndieGala Helper',
color: 'blue',
})
@@ -47,55 +47,47 @@ t.create('XML from url (attribute)')
.get(
'.json?url=https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/707078&query=/addon/reviews/@num'
)
.expectJSONTypes(
Joi.object().keys({
name: 'custom badge',
value: Joi.string().regex(/^\d+$/),
})
)
.expectBadge({
label: 'custom badge',
message: Joi.string().regex(/^\d+$/),
})
t.create('XML from url | multiple results')
.get(
'.json?url=https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/707078&query=/addon/compatible_applications/application/name'
)
.expectJSONTypes(
Joi.object().keys({
name: 'custom badge',
value: Joi.string().regex(
/^Firefox( for Android)?,\sFirefox( for Android)?$/
),
})
)
.expectBadge({
label: 'custom badge',
message: Joi.string().regex(
/^Firefox( for Android)?,\sFirefox( for Android)?$/
),
})
t.create('XML from url | caching with new query params')
.get(
'.json?url=https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/707078&query=/addon/version'
)
.expectJSONTypes(
Joi.object().keys({
name: 'custom badge',
value: isSemver,
})
)
.expectBadge({
label: 'custom badge',
message: isSemver,
})
t.create('XML from url | with prefix & suffix & label')
.get(
'.json?url=https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/707078&query=//version&prefix=v&suffix= dev&label=IndieGala Helper'
)
.expectJSONTypes(
Joi.object().keys({
name: 'IndieGala Helper',
value: Joi.string().regex(/^v\d+(\.\d+)?(\.\d+)?\sdev$/),
})
)
.expectBadge({
label: 'IndieGala Helper',
message: Joi.string().regex(/^v\d+(\.\d+)?(\.\d+)?\sdev$/),
})
t.create('XML from url | query doesnt exist')
.get(
'.json?url=https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/707078&query=/does/not/exist&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'no result',
.expectBadge({
label: 'custom badge',
message: 'no result',
color: 'lightgrey',
})
@@ -103,9 +95,9 @@ t.create('XML from url | query doesnt exist (attribute)')
.get(
'.json?url=https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/707078&query=/does/not/@exist&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'no result',
.expectBadge({
label: 'custom badge',
message: 'no result',
color: 'lightgrey',
})
@@ -113,9 +105,9 @@ t.create('XML from url | invalid url')
.get(
'.json?url=https://github.com/badges/shields/raw/master/notafile.xml&query=//version&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'resource not found',
.expectBadge({
label: 'custom badge',
message: 'resource not found',
color: 'red',
})
@@ -123,9 +115,9 @@ t.create('XML from url | user color overrides default')
.get(
'.json?url=https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/707078&query=/addon/name&color=10ADED&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'IndieGala Helper',
.expectBadge({
label: 'custom badge',
message: 'IndieGala Helper',
color: '#10aded',
})
@@ -133,17 +125,17 @@ t.create('XML from url | error color overrides default')
.get(
'.json?url=https://github.com/badges/shields/raw/master/notafile.xml&query=//version&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'resource not found',
.expectBadge({
label: 'custom badge',
message: 'resource not found',
color: 'red',
})
t.create('XML from url | error color overrides user specified')
.get('.json?query=//version&color=10ADED&style=_shields_test')
.expectJSON({
name: 'custom badge',
value: 'invalid query parameter: url',
.expectBadge({
label: 'custom badge',
message: 'invalid query parameter: url',
color: 'red',
})
@@ -158,7 +150,7 @@ t.create('XML from url | request should set Accept header')
return '<?xml version="1.0" encoding="utf-8" ?><name>dynamic xml</name>'
})
)
.expectJSON({ name: 'custom badge', value: 'dynamic xml' })
.expectBadge({ label: 'custom badge', message: 'dynamic xml' })
.after(() => {
expect(headers).to.have.property('accept', 'application/xml, text/xml')
})

View File

@@ -4,9 +4,9 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('No URL specified')
.get('.json?query=$.name&label=Package Name&style=_shields_test')
.expectJSON({
name: 'Package Name',
value: 'invalid query parameter: url',
.expectBadge({
label: 'Package Name',
message: 'invalid query parameter: url',
color: 'red',
})
@@ -14,9 +14,9 @@ t.create('No query specified')
.get(
'.json?url=https://raw.githubusercontent.com/kubernetes/charts/568291d6e476c39ca8322c30c3f601d0383d4760/stable/coredns/Chart.yaml&label=Package Name&style=_shields_test'
)
.expectJSON({
name: 'Package Name',
value: 'invalid query parameter: query',
.expectBadge({
label: 'Package Name',
message: 'invalid query parameter: query',
color: 'red',
})
@@ -24,9 +24,9 @@ t.create('YAML from url')
.get(
'.json?url=https://raw.githubusercontent.com/kubernetes/charts/568291d6e476c39ca8322c30c3f601d0383d4760/stable/coredns/Chart.yaml&query=$.name&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'coredns',
.expectBadge({
label: 'custom badge',
message: 'coredns',
color: 'blue',
})
@@ -34,9 +34,9 @@ t.create('YAML from uri (support uri query parameter)')
.get(
'.json?uri=https://raw.githubusercontent.com/kubernetes/charts/568291d6e476c39ca8322c30c3f601d0383d4760/stable/coredns/Chart.yaml&query=$.name&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'coredns',
.expectBadge({
label: 'custom badge',
message: 'coredns',
color: 'blue',
})
@@ -44,27 +44,27 @@ t.create('YAML from url | multiple results')
.get(
'.json?url=https://raw.githubusercontent.com/kubernetes/charts/568291d6e476c39ca8322c30c3f601d0383d4760/stable/coredns/Chart.yaml&query=$..keywords[0:2:1]'
)
.expectJSON({ name: 'custom badge', value: 'coredns, dns' })
.expectBadge({ label: 'custom badge', message: 'coredns, dns' })
t.create('YAML from url | caching with new query params')
.get(
'.json?url=https://raw.githubusercontent.com/kubernetes/charts/568291d6e476c39ca8322c30c3f601d0383d4760/stable/coredns/Chart.yaml&query=$.version'
)
.expectJSON({ name: 'custom badge', value: '0.8.0' })
.expectBadge({ label: 'custom badge', message: '0.8.0' })
t.create('YAML from url | with prefix & suffix & label')
.get(
'.json?url=https://raw.githubusercontent.com/kubernetes/charts/568291d6e476c39ca8322c30c3f601d0383d4760/stable/coredns/Chart.yaml&query=$.version&prefix=v&suffix= dev&label=Shields'
)
.expectJSON({ name: 'Shields', value: 'v0.8.0 dev' })
.expectBadge({ label: 'Shields', message: 'v0.8.0 dev' })
t.create('YAML from url | object doesnt exist')
.get(
'.json?url=https://raw.githubusercontent.com/kubernetes/charts/568291d6e476c39ca8322c30c3f601d0383d4760/stable/coredns/Chart.yaml&query=$.does_not_exist&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'no result',
.expectBadge({
label: 'custom badge',
message: 'no result',
color: 'lightgrey',
})
@@ -72,9 +72,9 @@ t.create('YAML from url | invalid url')
.get(
'.json?url=https://raw.githubusercontent.com/kubernetes/charts/568291d6e476c39ca8322c30c3f601d0383d4760/stable/coredns/notafile.yaml&query=$.version&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'resource not found',
.expectBadge({
label: 'custom badge',
message: 'resource not found',
color: 'red',
})
@@ -82,22 +82,22 @@ t.create('YAML from url | user color overrides default')
.get(
'.json?url=https://raw.githubusercontent.com/kubernetes/charts/568291d6e476c39ca8322c30c3f601d0383d4760/stable/coredns/Chart.yaml&query=$.name&color=10ADED&style=_shields_test'
)
.expectJSON({ name: 'custom badge', value: 'coredns', color: '#10aded' })
.expectBadge({ label: 'custom badge', message: 'coredns', color: '#10aded' })
t.create('YAML from url | error color overrides default')
.get(
'.json?url=https://raw.githubusercontent.com/kubernetes/charts/568291d6e476c39ca8322c30c3f601d0383d4760/stable/coredns/notafile.yaml&query=$.version&style=_shields_test'
)
.expectJSON({
name: 'custom badge',
value: 'resource not found',
.expectBadge({
label: 'custom badge',
message: 'resource not found',
color: 'red',
})
t.create('YAML from url | error color overrides user specified')
.get('.json?query=$.version&color=10ADED&style=_shields_test')
.expectJSON({
name: 'custom badge',
value: 'invalid query parameter: url',
.expectBadge({
label: 'custom badge',
message: 'invalid query parameter: url',
color: 'red',
})

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { ServiceTester } = require('../tester')
const { isMetric, isMetricOverTimePeriod } = require('../test-validators')
@@ -12,25 +11,21 @@ const t = (module.exports = new ServiceTester({
t.create('total marketplace downloads')
.get('/dt/notepad4e.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: isMetric,
})
)
.expectBadge({
label: 'downloads',
message: isMetric,
})
t.create('monthly marketplace downloads')
.get('/dm/notepad4e.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: isMetricOverTimePeriod,
})
)
.expectBadge({
label: 'downloads',
message: isMetricOverTimePeriod,
})
t.create('downloads for unknown solution')
.get('/dt/this-does-not-exist.json')
.expectJSON({
name: 'downloads',
value: 'solution not found',
.expectBadge({
label: 'downloads',
message: 'solution not found',
})

View File

@@ -5,18 +5,16 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('favorites count')
.get('/notepad4e.json')
.expectJSONTypes(
Joi.object().keys({
name: 'favorites',
value: Joi.number()
.integer()
.positive(),
})
)
.expectBadge({
label: 'favorites',
message: Joi.number()
.integer()
.positive(),
})
t.create('favorites for unknown solution')
.get('/this-does-not-exist.json')
.expectJSON({
name: 'favorites',
value: 'solution not found',
.expectBadge({
label: 'favorites',
message: 'solution not found',
})

View File

@@ -4,9 +4,9 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('license')
.get('/notepad4e.json')
.expectJSON({
name: 'license',
value: 'GPL',
.expectBadge({
label: 'license',
message: 'GPL',
})
t.create('unspecified license')
@@ -23,14 +23,14 @@ t.create('unspecified license')
</marketplace>`
)
)
.expectJSON({
name: 'license',
value: 'not specified',
.expectBadge({
label: 'license',
message: 'not specified',
})
t.create('license for unknown solution')
.get('/this-does-not-exist.json')
.expectJSON({
name: 'license',
value: 'solution not found',
.expectBadge({
label: 'license',
message: 'solution not found',
})

View File

@@ -1,21 +1,18 @@
'use strict'
const Joi = require('joi')
const { isFormattedDate } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('last update date')
.get('/notepad4e.json')
.expectJSONTypes(
Joi.object().keys({
name: 'updated',
value: isFormattedDate,
})
)
.expectBadge({
label: 'updated',
message: isFormattedDate,
})
t.create('last update for unknown solution')
.get('/this-does-not-exist.json')
.expectJSON({
name: 'updated',
value: 'solution not found',
.expectBadge({
label: 'updated',
message: 'solution not found',
})

View File

@@ -1,21 +1,18 @@
'use strict'
const Joi = require('joi')
const { isVPlusDottedVersionAtLeastOne } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('marketplace version')
.get('/notepad4e.json')
.expectJSONTypes(
Joi.object().keys({
name: 'eclipse marketplace',
value: isVPlusDottedVersionAtLeastOne,
})
)
.expectBadge({
label: 'eclipse marketplace',
message: isVPlusDottedVersionAtLeastOne,
})
t.create('last update for unknown solution')
.get('/this-does-not-exist.json')
.expectJSON({
name: 'eclipse marketplace',
value: 'solution not found',
.expectBadge({
label: 'eclipse marketplace',
message: 'solution not found',
})

View File

@@ -1,13 +1,12 @@
'use strict'
const Joi = require('joi')
const { isSemver } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('gets the package version of elm/core')
.get('/elm/core.json')
.expectJSONTypes(Joi.object().keys({ name: 'elm package', value: isSemver }))
.expectBadge({ label: 'elm package', message: isSemver })
t.create('invalid package name')
.get('/elm-community/frodo-is-not-a-package.json')
.expectJSON({ name: 'elm package', value: 'package not found' })
.expectBadge({ label: 'elm package', message: 'package not found' })

View File

@@ -15,7 +15,7 @@ t.create('Valid schema (mocked)')
message: 'yo',
})
)
.expectJSON({ name: '', value: 'yo' })
.expectBadge({ label: '', message: 'yo' })
t.create('color and labelColor')
.get('.json?url=https://example.com/badge&style=_shields_test')
@@ -50,9 +50,9 @@ t.create('style')
style: '_shields_test',
})
)
.expectJSON({
name: 'hey',
value: 'yo',
.expectBadge({
label: 'hey',
message: 'yo',
// `color` is only in _shields_test which is being specified by the
// service, not the request. If the color key is here we know this has
// worked.
@@ -145,9 +145,9 @@ t.create('Invalid schema (mocked)')
schemaVersion: -1,
})
)
.expectJSON({
name: 'custom badge',
value: 'invalid properties: schemaVersion',
.expectBadge({
label: 'custom badge',
message: 'invalid properties: schemaVersion',
})
t.create('Invalid schema (mocked)')
@@ -163,9 +163,9 @@ t.create('Invalid schema (mocked)')
bogus: true,
})
)
.expectJSON({
name: 'custom badge',
value: 'invalid properties: extra, bogus',
.expectBadge({
label: 'custom badge',
message: 'invalid properties: extra, bogus',
})
t.create('User color overrides success color')
@@ -180,7 +180,7 @@ t.create('User color overrides success color')
color: 'blue',
})
)
.expectJSON({ name: '', value: 'yo', color: '#101010' })
.expectBadge({ label: '', message: 'yo', color: '#101010' })
t.create('User legacy color overrides success color')
.get('.json?url=https://example.com/badge&colorB=101010&style=_shields_test')
@@ -194,7 +194,7 @@ t.create('User legacy color overrides success color')
color: 'blue',
})
)
.expectJSON({ name: '', value: 'yo', color: '#101010' })
.expectBadge({ label: '', message: 'yo', color: '#101010' })
t.create('User color does not override error color')
.get('.json?url=https://example.com/badge&color=101010&style=_shields_test')
@@ -209,7 +209,7 @@ t.create('User color does not override error color')
color: 'red',
})
)
.expectJSON({ name: 'something is', value: 'not right', color: 'red' })
.expectBadge({ label: 'something is', message: 'not right', color: 'red' })
t.create('User legacy color does not override error color')
.get('.json?url=https://example.com/badge&colorB=101010&style=_shields_test')
@@ -224,7 +224,7 @@ t.create('User legacy color does not override error color')
color: 'red',
})
)
.expectJSON({ name: 'something is', value: 'not right', color: 'red' })
.expectBadge({ label: 'something is', message: 'not right', color: 'red' })
t.create('cacheSeconds')
.get('.json?url=https://example.com/badge')
@@ -284,8 +284,8 @@ t.create('cacheSeconds does not override longer Shields default')
t.create('Bad scheme')
.get('.json?url=http://example.com/badge')
.expectJSON({ name: 'custom badge', value: 'please use https' })
.expectBadge({ label: 'custom badge', message: 'please use https' })
t.create('Blocked domain')
.get('.json?url=https://img.shields.io/badge/foo-bar-blue.json')
.expectJSON({ name: 'custom badge', value: 'domain is blocked' })
.expectBadge({ label: 'custom badge', message: 'domain is blocked' })

View File

@@ -1,6 +1,5 @@
'use strict'
const Joi = require('joi')
const { ServiceTester } = require('../tester')
const { isVPlusDottedVersionAtLeastOne } = require('../test-validators')
@@ -114,7 +113,7 @@ t.create('Package is found with default metadata format')
.get(`${path}.txt`)
.reply(200, testString)
)
.expectJSON({ name: 'f-droid', value: 'v1.4' })
.expectBadge({ label: 'f-droid', message: 'v1.4' })
t.create('Package is found with fallback yml matadata format')
.get('/v/axp.tool.apkextractor.json')
@@ -128,7 +127,7 @@ t.create('Package is found with fallback yml matadata format')
.get(`${path}.yml`)
.reply(200, testYmlString)
)
.expectJSON({ name: 'f-droid', value: 'v1.4' })
.expectBadge({ label: 'f-droid', message: 'v1.4' })
t.create('Package is found with yml matadata format')
.get('/v/axp.tool.apkextractor.json?metadata_format=yml')
@@ -137,7 +136,7 @@ t.create('Package is found with yml matadata format')
.get(`${path}.yml`)
.reply(200, testYmlString)
)
.expectJSON({ name: 'f-droid', value: 'v1.4' })
.expectBadge({ label: 'f-droid', message: 'v1.4' })
t.create('Package is not found with "metadata_format" query parameter')
.get('/v/axp.tool.apkextractor.json?metadata_format=yml')
@@ -146,7 +145,7 @@ t.create('Package is not found with "metadata_format" query parameter')
.get(`${path}.yml`)
.reply(404)
)
.expectJSON({ name: 'f-droid', value: 'app not found' })
.expectBadge({ label: 'f-droid', message: 'app not found' })
t.create('Package is found yml matadata format with missing "CurrentVersion"')
.get('/v/axp.tool.apkextractor.json?metadata_format=yml')
@@ -155,7 +154,7 @@ t.create('Package is found yml matadata format with missing "CurrentVersion"')
.get(`${path}.yml`)
.reply(200, 'Categories: System')
)
.expectJSON({ name: 'f-droid', value: 'invalid response data' })
.expectBadge({ label: 'f-droid', message: 'invalid response data' })
t.create('Package is found with bad yml matadata format')
.get('/v/axp.tool.apkextractor.json?metadata_format=yml')
@@ -164,7 +163,7 @@ t.create('Package is found with bad yml matadata format')
.get(`${path}.yml`)
.reply(200, '.CurrentVersion: 1.4')
)
.expectJSON({ name: 'f-droid', value: 'invalid response data' })
.expectBadge({ label: 'f-droid', message: 'invalid response data' })
t.create('Package is not found')
.get('/v/axp.tool.apkextractor.json')
@@ -178,7 +177,7 @@ t.create('Package is not found')
.get(`${path}.yml`)
.reply(404)
)
.expectJSON({ name: 'f-droid', value: 'app not found' })
.expectBadge({ label: 'f-droid', message: 'app not found' })
t.create('The api changed')
.get('/v/axp.tool.apkextractor.json?metadata_format=yml')
@@ -187,22 +186,20 @@ t.create('The api changed')
.get(`${path}.yml`)
.reply(200, '')
)
.expectJSON({ name: 'f-droid', value: 'invalid response data' })
.expectBadge({ label: 'f-droid', message: 'invalid response data' })
t.create('Package is not found due invalid metadata format')
.get('/v/axp.tool.apkextractor.json?metadata_format=xml')
.expectJSON({
name: 'f-droid',
value: 'invalid query parameter: metadata_format',
.expectBadge({
label: 'f-droid',
message: 'invalid query parameter: metadata_format',
})
/* If this test fails, either the API has changed or the app was deleted. */
t.create('The real api did not change')
.get('/v/org.thosp.yourlocalweather.json')
.timeout(10000)
.expectJSONTypes(
Joi.object().keys({
name: 'f-droid',
value: isVPlusDottedVersionAtLeastOne,
})
)
.expectBadge({
label: 'f-droid',
message: isVPlusDottedVersionAtLeastOne,
})

View File

@@ -1,74 +1,65 @@
'use strict'
const Joi = require('joi')
const { isMetric } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('total downloads (valid)')
.get('/dt/rails.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: isMetric,
})
)
.expectBadge({
label: 'downloads',
message: isMetric,
})
t.create('total downloads (not found)')
.get('/dt/not-a-package.json')
.expectJSON({ name: 'downloads', value: 'gem not found' })
.expectBadge({ label: 'downloads', message: 'gem not found' })
t.create('version downloads (valid, stable version)')
.get('/dv/rails/stable.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads@stable',
value: isMetric,
})
)
.expectBadge({
label: 'downloads@stable',
message: isMetric,
})
t.create('version downloads (valid, specific version)')
.get('/dv/rails/4.1.0.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads@4.1.0',
value: isMetric,
})
)
.expectBadge({
label: 'downloads@4.1.0',
message: isMetric,
})
t.create('version downloads (package not found)')
.get('/dv/not-a-package/4.1.0.json')
.expectJSON({ name: 'downloads', value: 'gem not found' })
.expectBadge({ label: 'downloads', message: 'gem not found' })
t.create('version downloads (valid package, invalid version)')
.get('/dv/rails/not-a-version.json')
.expectJSON({
name: 'downloads',
value: 'version should be "stable" or valid semver',
.expectBadge({
label: 'downloads',
message: 'version should be "stable" or valid semver',
})
t.create('version downloads (valid package, version not found)')
.get('/dv/rails/8.8.8.json')
.expectJSON({
name: 'downloads',
value: 'version not found',
.expectBadge({
label: 'downloads',
message: 'version not found',
})
t.create('version downloads (valid package, version not specified)')
.get('/dv/rails.json')
.expectJSON({
name: 'downloads',
value: 'version downloads requires a version',
.expectBadge({
label: 'downloads',
message: 'version downloads requires a version',
})
t.create('latest version downloads (valid)')
.get('/dtv/rails.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads@latest',
value: isMetric,
})
)
.expectBadge({
label: 'downloads@latest',
message: isMetric,
})
t.create('latest version downloads (not found)')
.get('/dtv/not-a-package.json')
.expectJSON({ name: 'downloads', value: 'gem not found' })
.expectBadge({ label: 'downloads', message: 'gem not found' })

View File

@@ -5,13 +5,11 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('users (valid)')
.get('/raphink.json')
.expectJSONTypes(
Joi.object().keys({
name: 'gems',
value: Joi.string().regex(/^[0-9]+$/),
})
)
.expectBadge({
label: 'gems',
message: Joi.string().regex(/^[0-9]+$/),
})
t.create('users (not found)')
.get('/not-a-package.json')
.expectJSON({ name: 'gems', value: 'not found' })
.expectBadge({ label: 'gems', message: 'not found' })

View File

@@ -10,25 +10,21 @@ const isOrdinalNumberDaily = Joi.string().regex(
t.create('total rank (valid)')
.get('/rt/rspec-puppet-facts.json')
.expectJSONTypes(
Joi.object().keys({
name: 'rank',
value: isOrdinalNumber,
})
)
.expectBadge({
label: 'rank',
message: isOrdinalNumber,
})
t.create('daily rank (valid)')
.get('/rd/rails.json')
.expectJSONTypes(
Joi.object().keys({
name: 'rank',
value: isOrdinalNumberDaily,
})
)
.expectBadge({
label: 'rank',
message: isOrdinalNumberDaily,
})
t.create('rank (not found)')
.get('/rt/not-a-package.json')
.expectJSON({ name: 'rank', value: 'not found' })
.expectBadge({ label: 'rank', message: 'not found' })
t.create('rank is null')
.get('/rd/rails.json')
@@ -42,4 +38,4 @@ t.create('rank is null')
},
])
)
.expectJSON({ name: 'rank', value: 'invalid rank' })
.expectBadge({ label: 'rank', message: 'invalid rank' })

View File

@@ -1,18 +1,15 @@
'use strict'
const Joi = require('joi')
const { isVPlusDottedVersionAtLeastOne } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('version (valid)')
.get('/formatador.json')
.expectJSONTypes(
Joi.object().keys({
name: 'gem',
value: isVPlusDottedVersionAtLeastOne,
})
)
.expectBadge({
label: 'gem',
message: isVPlusDottedVersionAtLeastOne,
})
t.create('version (not found)')
.get('/not-a-package.json')
.expectJSON({ name: 'gem', value: 'not found' })
.expectBadge({ label: 'gem', message: 'not found' })

View File

@@ -9,7 +9,7 @@ const t = (module.exports = new ServiceTester({
t.create('no longer available (previously dependencies)')
.get('/mathiasbynens/he.json')
.expectJSON({
name: 'gemnasium',
value: 'no longer available',
.expectBadge({
label: 'gemnasium',
message: 'no longer available',
})

View File

@@ -1,48 +1,39 @@
'use strict'
const Joi = require('joi')
const { isMetricOverTimePeriod } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('commit activity (1 year)')
.get('/y/eslint/eslint.json')
.expectJSONTypes(
Joi.object().keys({
name: 'commit activity',
value: isMetricOverTimePeriod,
})
)
.expectBadge({
label: 'commit activity',
message: isMetricOverTimePeriod,
})
t.create('commit activity (1 month)')
.get('/m/eslint/eslint.json')
.expectJSONTypes(
Joi.object().keys({
name: 'commit activity',
value: isMetricOverTimePeriod,
})
)
.expectBadge({
label: 'commit activity',
message: isMetricOverTimePeriod,
})
t.create('commit activity (4 weeks)')
.get('/4w/eslint/eslint.json')
.expectJSONTypes(
Joi.object().keys({
name: 'commit activity',
value: isMetricOverTimePeriod,
})
)
.expectBadge({
label: 'commit activity',
message: isMetricOverTimePeriod,
})
t.create('commit activity (1 week)')
.get('/w/eslint/eslint.json')
.expectJSONTypes(
Joi.object().keys({
name: 'commit activity',
value: isMetricOverTimePeriod,
})
)
.expectBadge({
label: 'commit activity',
message: isMetricOverTimePeriod,
})
t.create('commit activity (repo not found)')
.get('/w/badges/helmets.json')
.expectJSON({
name: 'commit activity',
value: 'repo not found',
.expectBadge({
label: 'commit activity',
message: 'repo not found',
})

View File

@@ -7,9 +7,9 @@ t.create('commit status - commit in branch')
.get(
'/badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c.json?style=_shields_test'
)
.expectJSON({
name: 'commit status',
value: 'in master',
.expectBadge({
label: 'commit status',
message: 'in master',
color: 'brightgreen',
})
@@ -26,9 +26,9 @@ t.create(
)
.reply(200, { status: 'identical' })
)
.expectJSON({
name: 'commit status',
value: 'in master',
.expectBadge({
label: 'commit status',
message: 'in master',
color: 'brightgreen',
})
@@ -36,9 +36,9 @@ t.create('commit status - commit not in branch')
.get(
'/badges/shields/master/960c5bf72d7d1539fcd453343eed3f8617427a41.json?style=_shields_test'
)
.expectJSON({
name: 'commit status',
value: 'commit or branch not found',
.expectBadge({
label: 'commit status',
message: 'commit or branch not found',
color: 'lightgrey',
})
@@ -46,9 +46,9 @@ t.create('commit status - unknown commit id')
.get(
'/atom/atom/v1.27.1/7dfb45eb61a48a4ce18a0dd2e31f944ed4467ae3.json?style=_shields_test'
)
.expectJSON({
name: 'commit status',
value: 'not in v1.27.1',
.expectBadge({
label: 'commit status',
message: 'not in v1.27.1',
color: 'yellow',
})
@@ -56,9 +56,9 @@ t.create('commit status - unknown branch')
.get(
'/badges/shields/this-branch-does-not-exist/b551a3a8daf1c48dba32a3eab1edf99b10c28863.json?style=_shields_test'
)
.expectJSON({
name: 'commit status',
value: 'commit or branch not found',
.expectBadge({
label: 'commit status',
message: 'commit or branch not found',
color: 'lightgrey',
})
@@ -66,9 +66,9 @@ t.create('commit status - no common ancestor between commit and branch')
.get(
'/badges/shields/master/b551a3a8daf1c48dba32a3eab1edf99b10c28863.json?style=_shields_test'
)
.expectJSON({
name: 'commit status',
value: 'no common ancestor',
.expectBadge({
label: 'commit status',
message: 'no common ancestor',
color: 'lightgrey',
})
@@ -83,9 +83,9 @@ t.create('commit status - invalid JSON')
)
.reply(invalidJSON)
)
.expectJSON({
name: 'commit status',
value: 'invalid',
.expectBadge({
label: 'commit status',
message: 'invalid',
color: 'lightgrey',
})
@@ -94,9 +94,9 @@ t.create('commit status - network error')
'/badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c.json?style=_shields_test'
)
.networkOff()
.expectJSON({
name: 'commit status',
value: 'inaccessible',
.expectBadge({
label: 'commit status',
message: 'inaccessible',
color: 'red',
})
@@ -111,9 +111,9 @@ t.create('commit status - github server error')
)
.reply(500)
)
.expectJSON({
name: 'commit status',
value: 'invalid',
.expectBadge({
label: 'commit status',
message: 'invalid',
color: 'lightgrey',
})
@@ -128,9 +128,9 @@ t.create('commit status - 404 with empty JSON form github')
)
.reply(404, {})
)
.expectJSON({
name: 'commit status',
value: 'invalid',
.expectBadge({
label: 'commit status',
message: 'invalid',
color: 'lightgrey',
})
@@ -145,8 +145,8 @@ t.create('commit status - 404 with invalid JSON form github')
)
.reply(404, invalidJSON)
)
.expectJSON({
name: 'commit status',
value: 'invalid',
.expectBadge({
label: 'commit status',
message: 'invalid',
color: 'lightgrey',
})

View File

@@ -7,19 +7,15 @@ t.create('Commits since')
.get(
'/badges/shields/a0663d8da53fb712472c02665e6ff7547ba945b7.json?style=_shields_test'
)
.expectJSONTypes(
Joi.object().keys({
name: Joi.string().regex(/^(commits since){1}[\s\S]+$/),
value: Joi.string().regex(/^\w+$/),
color: 'blue',
})
)
.expectBadge({
label: Joi.string().regex(/^(commits since){1}[\s\S]+$/),
message: Joi.string().regex(/^\w+$/),
color: 'blue',
})
t.create('Commits since by latest release')
.get('/microsoft/typescript/latest.json')
.expectJSONTypes(
Joi.object().keys({
name: Joi.string().regex(/^(commits since){1}[\s\S]+$/),
value: Joi.string().regex(/^\d+\w?$/),
})
)
.expectBadge({
label: Joi.string().regex(/^(commits since){1}[\s\S]+$/),
message: Joi.string().regex(/^\d+\w?$/),
})

View File

@@ -1,28 +1,25 @@
'use strict'
const Joi = require('joi')
const t = (module.exports = require('../tester').createServiceTester())
const { isMetric } = require('../test-validators')
t.create('Contributors')
.get('/contributors/cdnjs/cdnjs.json')
.expectJSONTypes(
Joi.object().keys({
name: 'contributors',
value: isMetric,
})
)
.expectBadge({
label: 'contributors',
message: isMetric,
})
t.create('1 contributor')
.get('/contributors/paulmelnikow/local-credential-storage.json')
.expectJSON({
name: 'contributors',
value: '1',
.expectBadge({
label: 'contributors',
message: '1',
})
t.create('Contributors (repo not found)')
.get('/contributors/badges/helmets.json')
.expectJSON({
name: 'contributors',
value: 'repo not found',
.expectBadge({
label: 'contributors',
message: 'repo not found',
})

View File

@@ -6,86 +6,72 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('Downloads all releases')
.get('/downloads/photonstorm/phaser/total.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: Joi.string().regex(/^\w+\s+total$/),
})
)
.expectBadge({
label: 'downloads',
message: Joi.string().regex(/^\w+\s+total$/),
})
t.create('Downloads all releases (repo not found)')
.get('/downloads/badges/helmets/total.json')
.expectJSON({
name: 'downloads',
value: 'repo or release not found',
.expectBadge({
label: 'downloads',
message: 'repo or release not found',
})
t.create('downloads for latest release')
.get('/downloads/photonstorm/phaser/latest/total.json')
.expectJSONTypes(Joi.object().keys({ name: 'downloads', value: isMetric }))
.expectBadge({ label: 'downloads', message: isMetric })
t.create('downloads-pre for latest release')
.get('/downloads-pre/photonstorm/phaser/latest/total.json')
.expectJSONTypes(Joi.object().keys({ name: 'downloads', value: isMetric }))
.expectBadge({ label: 'downloads', message: isMetric })
t.create('downloads for release without slash')
.get('/downloads/atom/atom/v0.190.0/total.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? v0\.190\.0$/),
})
)
.expectBadge({
label: 'downloads',
message: Joi.string().regex(/^[0-9]+[kMGTPEZY]? v0\.190\.0$/),
})
t.create('downloads for specific asset without slash')
.get('/downloads/atom/atom/v0.190.0/atom-amd64.deb.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: Joi.string().regex(
/^[0-9]+[kMGTPEZY]? v0\.190\.0 \[atom-amd64\.deb\]$/
),
})
)
.expectBadge({
label: 'downloads',
message: Joi.string().regex(
/^[0-9]+[kMGTPEZY]? v0\.190\.0 \[atom-amd64\.deb\]$/
),
})
t.create('downloads for specific asset from latest release')
.get('/downloads/atom/atom/latest/atom-amd64.deb.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? \[atom-amd64\.deb\]$/),
})
)
.expectBadge({
label: 'downloads',
message: Joi.string().regex(/^[0-9]+[kMGTPEZY]? \[atom-amd64\.deb\]$/),
})
t.create('downloads-pre for specific asset from latest release')
.get('/downloads-pre/atom/atom/latest/atom-amd64.deb.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? \[atom-amd64\.deb\]$/),
})
)
.expectBadge({
label: 'downloads',
message: Joi.string().regex(/^[0-9]+[kMGTPEZY]? \[atom-amd64\.deb\]$/),
})
t.create('downloads for release with slash')
.get('/downloads/NHellFire/dban/stable/v2.2.8/total.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? stable\/v2\.2\.8$/),
})
)
.expectBadge({
label: 'downloads',
message: Joi.string().regex(/^[0-9]+[kMGTPEZY]? stable\/v2\.2\.8$/),
})
t.create('downloads for specific asset with slash')
.get('/downloads/NHellFire/dban/stable/v2.2.8/dban-2.2.8_i586.iso.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: Joi.string().regex(
/^[0-9]+[kMGTPEZY]? stable\/v2\.2\.8 \[dban-2\.2\.8_i586\.iso\]$/
),
})
)
.expectBadge({
label: 'downloads',
message: Joi.string().regex(
/^[0-9]+[kMGTPEZY]? stable\/v2\.2\.8 \[dban-2\.2\.8_i586\.iso\]$/
),
})
t.create('downloads for unknown release')
.get('/downloads/atom/atom/does-not-exist/total.json')
.expectJSON({ name: 'downloads', value: 'repo or release not found' })
.expectBadge({ label: 'downloads', message: 'repo or release not found' })

View File

@@ -5,16 +5,14 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('Followers')
.get('/webcaetano.json')
.expectJSONTypes(
Joi.object().keys({
name: 'followers',
value: Joi.string().regex(/^\w+$/),
})
)
.expectBadge({
label: 'followers',
message: Joi.string().regex(/^\w+$/),
})
t.create('Followers (user not found)')
.get('/PyvesB2.json')
.expectJSON({
name: 'followers',
value: 'user not found',
.expectBadge({
label: 'followers',
message: 'user not found',
})

View File

@@ -5,18 +5,16 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('Forks')
.get('/badges/shields.json')
.expectJSONTypes(
Joi.object().keys({
name: 'forks',
value: Joi.number()
.integer()
.positive(),
})
)
.expectBadge({
label: 'forks',
message: Joi.number()
.integer()
.positive(),
})
t.create('Forks (repo not found)')
.get('/badges/helmets.json')
.expectJSON({
name: 'forks',
value: 'repo not found',
.expectBadge({
label: 'forks',
message: 'repo not found',
})

View File

@@ -6,62 +6,50 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('github issue state')
.get('/s/badges/shields/979.json')
.expectJSONTypes(
Joi.object().keys({
name: 'issue 979',
value: Joi.equal('open', 'closed'),
})
)
.expectBadge({
label: 'issue 979',
message: Joi.equal('open', 'closed'),
})
t.create('github issue state (repo not found)')
.get('/s/badges/helmets/979.json')
.expectJSON({
name: 'issue/pull request 979',
value: 'issue, pull request or repo not found',
.expectBadge({
label: 'issue/pull request 979',
message: 'issue, pull request or repo not found',
})
t.create('github issue title')
.get('/title/badges/shields/979.json')
.expectJSONTypes(
Joi.object().keys({
name: 'issue 979',
value: 'Github rate limits cause transient service test failures in CI',
})
)
.expectBadge({
label: 'issue 979',
message: 'Github rate limits cause transient service test failures in CI',
})
t.create('github issue author')
.get('/u/badges/shields/979.json')
.expectJSONTypes(Joi.object().keys({ name: 'author', value: 'paulmelnikow' }))
.expectBadge({ label: 'author', message: 'paulmelnikow' })
t.create('github issue label')
.get('/label/badges/shields/979.json')
.expectJSONTypes(
Joi.object().keys({
name: 'label',
value: Joi.equal(
'bug | developer-experience',
'developer-experience | bug'
),
})
)
.expectBadge({
label: 'label',
message: Joi.equal(
'bug | developer-experience',
'developer-experience | bug'
),
})
t.create('github issue comments')
.get('/comments/badges/shields/979.json')
.expectJSONTypes(
Joi.object().keys({
name: 'comments',
value: Joi.number().greater(15),
})
)
.expectBadge({
label: 'comments',
message: Joi.number().greater(15),
})
t.create('github issue age')
.get('/age/badges/shields/979.json')
.expectJSONTypes(
Joi.object().keys({ name: 'created', value: isFormattedDate })
)
.expectBadge({ label: 'created', message: isFormattedDate })
t.create('github issue update')
.get('/last-update/badges/shields/979.json')
.expectJSONTypes(
Joi.object().keys({ name: 'updated', value: isFormattedDate })
)
.expectBadge({ label: 'updated', message: isFormattedDate })

View File

@@ -6,130 +6,104 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('GitHub closed pull requests')
.get('/issues-pr-closed/badges/shields.json')
.expectJSONTypes(
Joi.object().keys({
name: 'pull requests',
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? closed$/),
})
)
.expectBadge({
label: 'pull requests',
message: Joi.string().regex(/^[0-9]+[kMGTPEZY]? closed$/),
})
t.create('GitHub closed pull requests raw')
.get('/issues-pr-closed-raw/badges/shields.json')
.expectJSONTypes(
Joi.object().keys({
name: 'closed pull requests',
value: Joi.string().regex(/^\w+?$/),
})
)
.expectBadge({
label: 'closed pull requests',
message: Joi.string().regex(/^\w+?$/),
})
t.create('GitHub pull requests')
.get('/issues-pr/badges/shields.json')
.expectJSONTypes(
Joi.object().keys({
name: 'pull requests',
value: isMetricOpenIssues,
})
)
.expectBadge({
label: 'pull requests',
message: isMetricOpenIssues,
})
t.create('GitHub pull requests raw')
.get('/issues-pr-raw/badges/shields.json')
.expectJSONTypes(
Joi.object().keys({
name: 'open pull requests',
value: isMetric,
})
)
.expectBadge({
label: 'open pull requests',
message: isMetric,
})
t.create('GitHub closed issues')
.get('/issues-closed/badges/shields.json')
.expectJSONTypes(
Joi.object().keys({
name: 'issues',
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? closed$/),
})
)
.expectBadge({
label: 'issues',
message: Joi.string().regex(/^[0-9]+[kMGTPEZY]? closed$/),
})
t.create('GitHub closed issues raw')
.get('/issues-closed-raw/badges/shields.json')
.expectJSONTypes(
Joi.object().keys({
name: 'closed issues',
value: Joi.string().regex(/^\w+\+?$/),
})
)
.expectBadge({
label: 'closed issues',
message: Joi.string().regex(/^\w+\+?$/),
})
t.create('GitHub open issues')
.get('/issues/badges/shields.json')
.expectJSONTypes(
Joi.object().keys({
name: 'issues',
value: isMetricOpenIssues,
})
)
.expectBadge({
label: 'issues',
message: isMetricOpenIssues,
})
t.create('GitHub open issues raw')
.get('/issues-raw/badges/shields.json')
.expectJSONTypes(Joi.object().keys({ name: 'open issues', value: isMetric }))
.expectBadge({ label: 'open issues', message: isMetric })
t.create('GitHub open issues by label is > zero')
.get('/issues/badges/shields/service-badge.json')
.expectJSONTypes(
Joi.object().keys({
name: 'service-badge issues',
value: isMetricOpenIssues,
})
)
.expectBadge({
label: 'service-badge issues',
message: isMetricOpenIssues,
})
t.create('GitHub open issues by multi-word label is > zero')
.get('/issues/Cockatrice/Cockatrice/App%20-%20Cockatrice.json')
.expectJSONTypes(
Joi.object().keys({
name: '"app - cockatrice" issues',
value: isMetricOpenIssues,
})
)
.expectBadge({
label: '"app - cockatrice" issues',
message: isMetricOpenIssues,
})
t.create('GitHub open issues by label (raw)')
.get('/issues-raw/badges/shields/service-badge.json')
.expectJSONTypes(
Joi.object().keys({
name: 'open service-badge issues',
value: isMetric,
})
)
.expectBadge({
label: 'open service-badge issues',
message: isMetric,
})
// https://github.com/badges/shields/issues/1870
t.create('GitHub open issues by label including slash character (raw)')
.get('/issues-raw/IgorNovozhilov/ndk/@ndk/cfg.json')
.expectJSONTypes(
Joi.object().keys({
name: 'open @ndk/cfg issues',
// Not always > 0.
value: Joi.alternatives(isMetric, Joi.equal('0')),
})
)
.expectBadge({
label: 'open @ndk/cfg issues',
// Not always > 0.
message: Joi.alternatives(isMetric, Joi.equal('0')),
})
t.create('GitHub open issues (repo not found)')
.get('/issues-raw/badges/helmets.json')
.expectJSON({
name: 'open issues',
value: 'repo not found',
.expectBadge({
label: 'open issues',
message: 'repo not found',
})
t.create('GitHub open pull requests by label')
.get('/issues-pr/badges/shields/service-badge.json')
.expectJSONTypes(
Joi.object().keys({
name: 'service-badge pull requests',
value: isMetricOpenIssues,
})
)
.expectBadge({
label: 'service-badge pull requests',
message: isMetricOpenIssues,
})
t.create('GitHub open pull requests by label (raw)')
.get('/issues-pr-raw/badges/shields/service-badge.json')
.expectJSONTypes(
Joi.object().keys({
name: 'open service-badge pull requests',
value: isMetric,
})
)
.expectBadge({
label: 'open service-badge pull requests',
message: isMetric,
})

Some files were not shown because too many files have changed in this diff Show More