Make [Coveralls] examples consistent with regards to VCS parameter (#6181)

* Make [Coveralls] examples consistent with regards to VCS parameter

* Implement redirector for missing VCS type
This commit is contained in:
Pierre-Yves B
2021-02-24 10:08:37 +00:00
committed by GitHub
parent 322eafd5ac
commit 66a73b9f98
4 changed files with 35 additions and 26 deletions

View File

@@ -0,0 +1,17 @@
'use strict'
const { redirector } = require('..')
module.exports = [
redirector({
name: 'CoverallsGitHubRedirect',
category: 'coverage',
route: {
base: 'coveralls',
pattern: ':user((?!github|bitbucket).*)/:repo/:branch*',
},
transformPath: ({ user, repo, branch }) =>
`/coveralls/github/${user}/${repo}${branch ? `/${branch}` : ''}`,
dateAdded: new Date('2021-02-23'),
}),
]

View File

@@ -0,0 +1,13 @@
'use strict'
const { ServiceTester } = require('../tester')
const t = (module.exports = new ServiceTester({
id: 'CoverallsGitHubRedirect',
title: 'Coveralls GitHub Redirector',
pathPrefix: '/coveralls',
}))
t.create('Coveralls VCS type missing')
.get('/lemurheavy/coveralls-ruby.svg')
.expectRedirect('/coveralls/github/lemurheavy/coveralls-ruby.svg')

View File

@@ -12,42 +12,25 @@ module.exports = class Coveralls extends BaseJsonService {
static category = 'coverage'
static route = {
base: 'coveralls',
pattern: ':vcsType(github|bitbucket)?/:user/:repo/:branch*',
pattern: ':vcsType(github|bitbucket)/:user/:repo/:branch*',
}
static examples = [
{
title: 'Coveralls github',
pattern: ':vcsType/:user/:repo',
title: 'Coveralls',
namedParams: { vcsType: 'github', user: 'jekyll', repo: 'jekyll' },
pattern: ':vcsType(github|bitbucket)/:user/:repo',
staticPreview: this.render({ coverage: 86 }),
},
{
title: 'Coveralls github branch',
pattern: ':vcsType/:user/:repo/:branch',
namedParams: {
vcsType: 'github',
user: 'lemurheavy',
repo: 'coveralls-ruby',
branch: 'master',
},
staticPreview: this.render({ coverage: 91.81 }),
},
{
title: 'Coveralls bitbucket',
pattern: ':vcsType/:user/:repo',
namedParams: { vcsType: 'bitbucket', user: 'pyKLIP', repo: 'pyklip' },
staticPreview: this.render({ coverage: 86 }),
},
{
title: 'Coveralls bitbucket branch',
pattern: ':vcsType/:user/:repo/:branch',
title: 'Coveralls branch',
namedParams: {
vcsType: 'bitbucket',
user: 'pyKLIP',
repo: 'pyklip',
branch: 'master',
},
pattern: ':vcsType(github|bitbucket)/:user/:repo/:branch',
staticPreview: this.render({ coverage: 96 }),
},
]

View File

@@ -15,10 +15,6 @@ t.create('github branch coverage')
.get('/github/lemurheavy/coveralls-ruby/master.json')
.expectBadge({ label: 'coverage', message: isIntegerPercentage })
t.create('github coverage for legacy link')
.get('/jekyll/jekyll.json')
.expectBadge({ label: 'coverage', message: isIntegerPercentage })
t.create('bitbucket coverage')
.get('/bitbucket/pyKLIP/pyklip.json')
.expectBadge({ label: 'coverage', message: isIntegerPercentage })