@@ -6,6 +6,7 @@ import { expect } from 'chai';
66describe ( 'db config store' , async ( ) => {
77 const tempWorkspaceStoragePath = path . join ( __dirname , 'test-workspace' ) ;
88 const testDataStoragePath = path . join ( __dirname , 'data' ) ;
9+ const corruptedTestDataStoragePath = path . join ( __dirname , 'corruptedData' ) ;
910
1011 beforeEach ( async ( ) => {
1112 await fs . ensureDir ( tempWorkspaceStoragePath ) ;
@@ -53,4 +54,28 @@ describe('db config store', async () => {
5354 const reRetrievedConfig = configStore . getConfig ( ) ;
5455 expect ( reRetrievedConfig . remote . repositoryLists ) . to . have . length ( 1 ) ;
5556 } ) ;
57+
58+ it ( 'should return error when file is not valid' , async ( ) => {
59+ const configStore = new DbConfigStore ( corruptedTestDataStoragePath ) ;
60+ await configStore . initialize ( ) ;
61+
62+ const validationOutput = configStore . validateConfig ( ) ;
63+ expect ( validationOutput ) . to . have . length ( 2 ) ;
64+ if ( validationOutput ) {
65+ expect ( validationOutput [ 0 ] ) . to . deep . equal ( {
66+ 'instancePath' : '/remote' ,
67+ 'keyword' : 'required' ,
68+ 'message' : 'must have required property \'owners\'' ,
69+ 'params' : { 'missingProperty' : 'owners' } ,
70+ 'schemaPath' : '#/properties/remote/required'
71+ } ) ;
72+ expect ( validationOutput [ 1 ] ) . to . deep . equal ( {
73+ 'instancePath' : '/remote' ,
74+ 'keyword' : 'additionalProperties' ,
75+ 'message' : 'must NOT have additional properties' ,
76+ 'params' : { 'additionalProperty' : 'somethingElse' } ,
77+ 'schemaPath' : '#/properties/remote/additionalProperties'
78+ } ) ;
79+ }
80+ } ) ;
5681} ) ;
0 commit comments