@@ -9,11 +9,13 @@ import {
99 addBranchStats ,
1010 addExtractionStats ,
1111 exportStats ,
12+ finalizeReport ,
1213 getReport ,
1314} from './reporting' ;
1415
1516jest . mock ( '../util/fs' , ( ) => mockDeep ( ) ) ;
1617jest . mock ( '../util/s3' , ( ) => mockDeep ( ) ) ;
18+ jest . mock ( '../logger' , ( ) => mockDeep ( ) ) ;
1719
1820describe ( 'instrumentation/reporting' , ( ) => {
1921 const branchInformation : Partial < BranchCache > [ ] = [
@@ -52,8 +54,10 @@ describe('instrumentation/reporting', () => {
5254 } ;
5355
5456 const expectedReport = {
57+ problems : [ ] ,
5558 repositories : {
5659 'myOrg/myRepo' : {
60+ problems : [ ] ,
5761 branches : branchInformation ,
5862 packageFiles,
5963 } ,
@@ -70,6 +74,7 @@ describe('instrumentation/reporting', () => {
7074 } ) ;
7175
7276 expect ( getReport ( ) ) . toEqual ( {
77+ problems : [ ] ,
7378 repositories : { } ,
7479 } ) ;
7580 } ) ;
@@ -174,4 +179,49 @@ describe('instrumentation/reporting', () => {
174179 fs . writeSystemFile . mockRejectedValue ( null ) ;
175180 await expect ( exportStats ( config ) ) . toResolve ( ) ;
176181 } ) ;
182+
183+ it ( 'should add problems to report' , ( ) => {
184+ const config : RenovateConfig = {
185+ repository : 'myOrg/myRepo' ,
186+ reportType : 'logging' ,
187+ } ;
188+ const expectedReport = {
189+ problems : [
190+ {
191+ level : 30 ,
192+ msg : 'a root problem' ,
193+ } ,
194+ ] ,
195+ repositories : {
196+ 'myOrg/myRepo' : {
197+ problems : [
198+ {
199+ level : 30 ,
200+ msg : 'a repo problem' ,
201+ } ,
202+ ] ,
203+ branches : branchInformation ,
204+ packageFiles,
205+ } ,
206+ } ,
207+ } ;
208+
209+ addBranchStats ( config , branchInformation ) ;
210+ addExtractionStats ( config , { branchList : [ ] , branches : [ ] , packageFiles } ) ;
211+
212+ logger . getProblems . mockReturnValue ( [
213+ {
214+ repository : 'myOrg/myRepo' ,
215+ level : 30 ,
216+ msg : 'a repo problem' ,
217+ } ,
218+ {
219+ level : 30 ,
220+ msg : 'a root problem' ,
221+ } ,
222+ ] ) ;
223+ finalizeReport ( ) ;
224+
225+ expect ( getReport ( ) ) . toEqual ( expectedReport ) ;
226+ } ) ;
177227} ) ;
0 commit comments