fix: SymfonyInsight transform (#4877)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const Joi = require('@hapi/joi')
|
||||
const { BaseXmlService } = require('..')
|
||||
const { BaseXmlService, NotFound } = require('..')
|
||||
|
||||
const violationSchema = Joi.object({
|
||||
severity: Joi.equal('info', 'minor', 'major', 'critical').required(),
|
||||
@@ -87,6 +87,11 @@ class SymfonyInsightBase extends BaseXmlService {
|
||||
|
||||
transform({ data }) {
|
||||
const lastAnalysis = data.project['last-analysis']
|
||||
|
||||
if (!lastAnalysis) {
|
||||
throw new NotFound({ prettyMessage: 'no analyses found' })
|
||||
}
|
||||
|
||||
let numViolations = 0
|
||||
let numCriticalViolations = 0
|
||||
let numMajorViolations = 0
|
||||
|
||||
21
services/symfony/symfony-insight-base.spec.js
Normal file
21
services/symfony/symfony-insight-base.spec.js
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict'
|
||||
|
||||
const { expect } = require('chai')
|
||||
const { SymfonyInsightBase } = require('./symfony-insight-base')
|
||||
const { NotFound } = require('..')
|
||||
|
||||
describe('SymfonyInsightBase', function() {
|
||||
context('transform()', function() {
|
||||
it('throws NotFound error when there is no coverage data', function() {
|
||||
try {
|
||||
SymfonyInsightBase.prototype.transform({
|
||||
data: { project: {} },
|
||||
})
|
||||
expect.fail('Expected to throw')
|
||||
} catch (e) {
|
||||
expect(e).to.be.an.instanceof(NotFound)
|
||||
expect(e.prettyMessage).to.equal('no analyses found')
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user