Remove unused callback-based error helpers (#3371)

This commit is contained in:
Paul Melnikow
2019-04-29 13:35:57 -04:00
committed by GitHub
parent ca4763b0ff
commit a0492c5283
6 changed files with 14 additions and 134 deletions

View File

@@ -2,9 +2,6 @@
const serverSecrets = require('../../lib/server-secrets')
const { colorScale } = require('../color-formatters')
const {
checkErrorResponse: standardCheckErrorResponse,
} = require('../../lib/error-helper')
const documentation = `
<p>
@@ -27,19 +24,6 @@ function errorMessagesFor(notFoundMessage = 'repo not found') {
}
}
function checkErrorResponse(
badgeData,
err,
res,
notFoundMessage = 'repo not found',
errorMessages = {}
) {
return standardCheckErrorResponse(badgeData, err, res, {
...errorMessages,
...errorMessagesFor(notFoundMessage),
})
}
const commentsColor = colorScale([1, 3, 10, 25], undefined, true)
function staticAuthConfigured() {
@@ -51,6 +35,5 @@ module.exports = {
stateColor,
commentsColor,
errorMessagesFor,
checkErrorResponse,
staticAuthConfigured,
}

View File

@@ -1,37 +0,0 @@
'use strict'
const { expect } = require('chai')
const { checkErrorResponse } = require('./github-helpers')
describe('GitHub Error Handler', function() {
it('makes repo not found badge when 422 is returned', function() {
const badgeData = { text: [] }
expect(checkErrorResponse(badgeData, null, { statusCode: 422 })).to.be.true
expect(badgeData.text[1]).to.equal('repo not found')
expect(badgeData.colorscheme).to.equal('lightgrey')
})
it('makes user not found badge when 404 is returned', function() {
const badgeData = { text: [] }
expect(
checkErrorResponse(badgeData, null, { statusCode: 404 }, 'user not found')
).to.be.true
expect(badgeData.text[1]).to.equal('user not found')
expect(badgeData.colorscheme).to.equal('lightgrey')
})
it('makes badge with custom message when specified', function() {
const badgeData = { text: [] }
expect(
checkErrorResponse(
badgeData,
null,
{ statusCode: 418 },
'repo not found',
{ 418: "I'm a teapot" }
)
).to.be.true
expect(badgeData.text[1]).to.equal("I'm a teapot")
expect(badgeData.colorscheme).to.equal('lightgrey')
})
})