Handle [cpan] versions that aren't returned as strings (#5239)

This commit is contained in:
Pierre-Yves B
2020-06-25 08:26:23 +02:00
committed by GitHub
parent f02df4f826
commit 9acc305d31
2 changed files with 16 additions and 1 deletions

View File

@@ -8,6 +8,21 @@ t.create('version (valid)').get('/Config-Augeas.json').expectBadge({
message: isVPlusDottedVersionAtLeastOne,
})
t.create('version (version is a number rather than a string)')
.get('/Config-Augeas.json')
.intercept(nock =>
nock('https://fastapi.metacpan.org')
.get('/v1/release/Config-Augeas')
.reply(200, {
license: ['GPL'],
version: 0.88,
})
)
.expectBadge({
label: 'cpan',
message: 'v0.88',
})
t.create('version (not found)').get('/not-a-package.json').expectBadge({
label: 'cpan',
message: 'not found',

View File

@@ -4,7 +4,7 @@ const Joi = require('@hapi/joi')
const { BaseJsonService } = require('..')
const schema = Joi.object({
version: Joi.string().required(),
version: Joi.alternatives(Joi.string().required(), Joi.number().required()),
license: Joi.array().items(Joi.string()).min(1).required(),
}).required()