Files
shields/services/appveyor/appveyor-base.js
Paul Melnikow fafb22efee Move "good" badge helpers from lib/ to services/ (#3101)
This moves a few helpers from `lib/` to `services/`:

build-status.js
build-status.spec.js
color-formatters.js
color-formatters.spec.js
contributor-count.js
licenses.js
licenses.spec.js
php-version.js
php-version.spec.js
text-formatters.js
text-formatters.spec.js
version.js
version.spec.js

And one from `lib/` to `core/`:

unhandled-rejection.spec.js

The diff is long, but the changes are straightforward.

Ref #2832
2019-02-27 20:47:46 -05:00

45 lines
1014 B
JavaScript

'use strict'
const Joi = require('joi')
const { BaseJsonService } = require('..')
const { nonNegativeInteger } = require('../validators')
const { isBuildStatus } = require('../build-status')
const schema = Joi.object({
build: Joi.object({
status: isBuildStatus,
jobs: Joi.array()
.items({
testsCount: nonNegativeInteger,
passedTestsCount: nonNegativeInteger,
failedTestsCount: nonNegativeInteger,
})
.required(),
}),
}).required()
module.exports = class AppVeyorBase extends BaseJsonService {
static get category() {
return 'build'
}
async fetch({ user, repo, branch }) {
let url = `https://ci.appveyor.com/api/projects/${user}/${repo}`
if (branch != null) {
url += `/branch/${branch}`
}
return this._requestJson({
schema,
url,
errorMessages: { 404: 'project not found or access denied' },
})
}
static buildRoute(base) {
return {
base,
pattern: ':user/:repo/:branch*',
}
}
}