Skip to content

Commit

Permalink
Set static previews for [jenkins jenkinsplugin] and tweak tests (#2765)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmelnikow authored Jan 15, 2019
1 parent 394a411 commit a58de54
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 62 deletions.
15 changes: 13 additions & 2 deletions services/jenkins/jenkins-build.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,26 @@ module.exports = class JenkinsBuild extends LegacyService {
static get route() {
return {
base: 'jenkins/s',
pattern: ':scheme(http|https)?/:host/:job*',
}
}

static get examples() {
return [
{
title: 'Jenkins',
previewUrl:
'https/jenkins.qa.ubuntu.com/view/Precise/view/All%20Precise/job/precise-desktop-amd64_default',
pattern: ':scheme/:host/:job',
namedParams: {
scheme: 'https',
host: 'jenkins.qa.ubuntu.com',
job:
'view/Precise/view/All%20Precise/job/precise-desktop-amd64_default',
},
staticPreview: {
label: 'build',
message: 'passing',
color: 'brightgreen',
},
},
]
}
Expand Down
57 changes: 0 additions & 57 deletions services/jenkins/jenkins-plugin-installs.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,10 @@ t.create('total installs | valid')
})
)

t.create('total installs | invalid: no "installations" property')
.get('/view-job-filters.json')
.intercept(nock =>
nock('https://stats.jenkins.io')
.get('/plugin-installation-trend/view-job-filters.stats.json')
.reply(200, { name: 'view-job-filters' })
)
.expectJSON({ name: 'installs', value: 'invalid response data' })

t.create('total installs | invalid: empty "installations" object')
.get('/view-job-filters.json')
.intercept(nock =>
nock('https://stats.jenkins.io')
.get('/plugin-installation-trend/view-job-filters.stats.json')
.reply(200, { name: 'view-job-filters', installations: {} })
)
.expectJSON({ name: 'installs', value: 'invalid response data' })

t.create('total installs | invalid: non-numeric "installations" key')
.get('/view-job-filters.json')
.intercept(nock =>
nock('https://stats.jenkins.io')
.get('/plugin-installation-trend/view-job-filters.stats.json')
.reply(200, { name: 'view-job-filters', installations: { abc: 12345 } })
)
.expectJSON({ name: 'installs', value: 'invalid response data' })

t.create('total installs | not found')
.get('/not-a-plugin.json')
.expectJSON({ name: 'installs', value: 'plugin not found' })

t.create('total installs | inaccessible: connection error')
.get('/view-job-filters.json')
.networkOff()
.expectJSON({ name: 'installs', value: 'inaccessible' })

// version installs

t.create('version installs | valid: numeric version')
Expand All @@ -72,35 +40,10 @@ t.create('version installs | valid: alphanumeric version')
})
)

t.create('version installs | invalid: "installationsPerVersion" missing')
.get('/view-job-filters/1.26.json')
.intercept(nock =>
nock('https://stats.jenkins.io')
.get('/plugin-installation-trend/view-job-filters.stats.json')
.reply(200, { name: 'view-job-filters' })
)
.expectJSON({ name: 'installs', value: 'invalid response data' })

t.create('version installs | invalid: empty "installationsPerVersion" object')
.get('/view-job-filters/1.26.json')
.intercept(nock =>
nock('https://stats.jenkins.io')
.get('/plugin-installation-trend/view-job-filters.stats.json')
.reply(200, { name: 'view-job-filters', installationsPerVersion: {} })
)
.expectJSON({ name: 'installs', value: 'invalid response data' })

t.create('version installs | not found: non-existent plugin')
.get('/not-a-plugin/1.26.json')
.expectJSON({ name: 'installs', value: 'plugin not found' })

t.create('version installs | not found: non-existent version')
.get('/view-job-filters/1.1-NOT-FOUND.json')
.expectJSON({ name: 'installs', value: 'version not found' })

t.create('version installs | inaccessible: connection error')
.get('/view-job-filters/1.26.json')
.networkOff()
.expectJSON({ name: 'installs', value: 'inaccessible' })

module.exports = t
10 changes: 9 additions & 1 deletion services/jenkins/jenkins-plugin-version.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ module.exports = class JenkinsPlugin extends LegacyService {
return [
{
title: 'Jenkins Plugins',
previewUrl: 'blueocean',
pattern: ':plugin',
namedParams: {
plugin: 'blueocean',
},
staticPreview: {
label: 'plugin',
message: 'v1.10.1',
color: 'blue',
},
},
]
}
Expand Down
15 changes: 13 additions & 2 deletions services/jenkins/jenkins-tests.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,26 @@ module.exports = class JenkinsTests extends LegacyService {
static get route() {
return {
base: 'jenkins/t',
pattern: ':scheme(http|https)?/:host/:job*',
}
}

static get examples() {
return [
{
title: 'Jenkins tests',
previewUrl:
'https/jenkins.qa.ubuntu.com/view/Precise/view/All%20Precise/job/precise-desktop-amd64_default',
pattern: ':scheme/:host/:job',
namedParams: {
scheme: 'https',
host: 'jenkins.qa.ubuntu.com',
job:
'view/Precise/view/All%20Precise/job/precise-desktop-amd64_default',
},
staticPreview: {
label: 'build',
message: 'passing',
color: 'brightgreen',
},
},
]
}
Expand Down

0 comments on commit a58de54

Please sign in to comment.