- Replace the idea of color schemes with the idea of named colors (since none of our colorschemes have used `colorA`)
- Pass through the normalized color to `_shields_test` to harmonize with BaseService and simplify testing
- Update service tests
- Move responsibility for color generation into the npm package
- Remove several color helper functions and their tests
- Update gh-badge public API to accept `color` and `labelColor`
This is a precursor to refactoring some of the logo code for #2473.
56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
'use strict'
|
|
|
|
const Joi = require('joi')
|
|
const { dockerBlue } = require('./docker-helpers')
|
|
const { isBuildStatus } = require('../../lib/build-status')
|
|
|
|
const t = (module.exports = require('../create-service-tester')())
|
|
|
|
t.create('docker build status (valid, user)')
|
|
.get('/jrottenberg/ffmpeg.json')
|
|
.expectJSONTypes(
|
|
Joi.object().keys({
|
|
name: 'docker build',
|
|
value: isBuildStatus,
|
|
})
|
|
)
|
|
|
|
t.create('docker build status (not found)')
|
|
.get('/_/not-a-real-repo.json')
|
|
.expectJSON({ name: 'docker build', value: 'repo not found' })
|
|
|
|
t.create('docker build status (passing)')
|
|
.get('/_/ubuntu.json?style=_shields_test')
|
|
.intercept(nock =>
|
|
nock('https://registry.hub.docker.com/')
|
|
.get('/v2/repositories/library/ubuntu/buildhistory')
|
|
.reply(200, { results: [{ status: 10 }] })
|
|
)
|
|
.expectJSON({
|
|
name: 'docker build',
|
|
value: 'passing',
|
|
color: 'brightgreen',
|
|
})
|
|
|
|
t.create('docker build status (failing)')
|
|
.get('/_/ubuntu.json?style=_shields_test')
|
|
.intercept(nock =>
|
|
nock('https://registry.hub.docker.com/')
|
|
.get('/v2/repositories/library/ubuntu/buildhistory')
|
|
.reply(200, { results: [{ status: -1 }] })
|
|
)
|
|
.expectJSON({ name: 'docker build', value: 'failing', color: 'red' })
|
|
|
|
t.create('docker build status (building)')
|
|
.get('/_/ubuntu.json?style=_shields_test')
|
|
.intercept(nock =>
|
|
nock('https://registry.hub.docker.com/')
|
|
.get('/v2/repositories/library/ubuntu/buildhistory')
|
|
.reply(200, { results: [{ status: 1 }] })
|
|
)
|
|
.expectJSON({
|
|
name: 'docker build',
|
|
value: 'building',
|
|
color: `#${dockerBlue}`,
|
|
})
|