@@ -2,7 +2,7 @@ import test, { ExecutionContext } from "ava";
22
33import { RepositoryProperties } from "../feature-flags/properties" ;
44import { KnownLanguage , Language } from "../languages" ;
5- import { prettyPrintPack } from "../util" ;
5+ import { ConfigurationError , prettyPrintPack } from "../util" ;
66
77import * as dbConfig from "./db-config" ;
88
@@ -391,3 +391,43 @@ test(
391391 { } ,
392392 / " a - p a c k - w i t h o u t - a - s c o p e " i s n o t a v a l i d p a c k / ,
393393) ;
394+
395+ test ( "parseUserConfig - successfully parses valid YAML" , ( t ) => {
396+ const result = dbConfig . parseUserConfig (
397+ "test" ,
398+ `
399+ paths-ignore:
400+ - "some/path"
401+ queries:
402+ - foo
403+
404+ ` ,
405+ ) ;
406+ t . truthy ( result ) ;
407+ if ( t . truthy ( result [ "paths-ignore" ] ) ) {
408+ t . is ( result [ "paths-ignore" ] . length , 1 ) ;
409+ t . is ( result [ "paths-ignore" ] [ 0 ] , "some/path" ) ;
410+ }
411+ if ( t . truthy ( result [ "queries" ] ) ) {
412+ t . is ( result [ "queries" ] . length , 1 ) ;
413+ t . is ( result [ "queries" ] [ 0 ] , "foo" ) ;
414+ }
415+ } ) ;
416+
417+ test ( "parseUserConfig - throws a ConfigurationError if the file is not valid YAML" , ( t ) => {
418+ t . throws (
419+ ( ) =>
420+ dbConfig . parseUserConfig (
421+ "test" ,
422+ `
423+ paths-ignore:
424+ - "some/path"
425+ queries:
426+ - foo
427+ ` ,
428+ ) ,
429+ {
430+ instanceOf : ConfigurationError ,
431+ } ,
432+ ) ;
433+ } ) ;
0 commit comments