1. Add validation to BaseSvgScrapingService and update readthedocs accordingly. 2. Rewrite vso and add more tests. Rename it internally to azure-devops. URLs are still `/vso` for now. Should we make a way to let a service register multiple URL patterns? 3. Handle shared code using a functional pattern instead of inheritance. This comes from a discussion https://github.com/badges/shields/pull/2031#issuecomment-417893819. I like the functional approach because it's more direct, nimble, and easy to reason about; plus it allows services to grow from a family of one to two more easily.
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
'use strict'
|
|
|
|
const Joi = require('joi')
|
|
const { isBuildStatus } = require('../test-validators')
|
|
const t = require('../create-service-tester')()
|
|
module.exports = t
|
|
|
|
// https://dev.azure.com/totodem/Shields.io is a public Azure DevOps project
|
|
// solely created for Shields.io testing.
|
|
|
|
t.create('default branch')
|
|
.get(
|
|
'/azure-devops/build/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2.json'
|
|
)
|
|
.expectJSONTypes(
|
|
Joi.object().keys({
|
|
name: 'build',
|
|
value: isBuildStatus,
|
|
})
|
|
)
|
|
|
|
t.create('named branch')
|
|
.get(
|
|
'/azure-devops/build/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2/master.json'
|
|
)
|
|
.expectJSONTypes(
|
|
Joi.object().keys({
|
|
name: 'build',
|
|
value: isBuildStatus,
|
|
})
|
|
)
|
|
|
|
t.create('unknown definition')
|
|
.get(
|
|
'/azure-devops/build/larsbrinkhoff/953a34b9-5966-4923-a48a-c41874cfb5f5/515.json'
|
|
)
|
|
.expectJSON({ name: 'build', value: 'definition not found' })
|
|
|
|
t.create('unknown project')
|
|
.get('/azure-devops/build/larsbrinkhoff/foo/515.json')
|
|
.expectJSON({ name: 'build', value: 'user or project not found' })
|
|
|
|
t.create('unknown user')
|
|
.get('/azure-devops/build/notarealuser/foo/515.json')
|
|
.expectJSON({ name: 'build', value: 'user or project not found' })
|