@@ -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,42 @@ 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+ - uses: foo
403+ ` ,
404+ ) ;
405+ t . truthy ( result ) ;
406+ if ( t . truthy ( result [ "paths-ignore" ] ) ) {
407+ t . is ( result [ "paths-ignore" ] . length , 1 ) ;
408+ t . is ( result [ "paths-ignore" ] [ 0 ] , "some/path" ) ;
409+ }
410+ if ( t . truthy ( result [ "queries" ] ) ) {
411+ t . is ( result [ "queries" ] . length , 1 ) ;
412+ t . deepEqual ( result [ "queries" ] [ 0 ] , { uses : "foo" } ) ;
413+ }
414+ } ) ;
415+
416+ test ( "parseUserConfig - throws a ConfigurationError if the file is not valid YAML" , ( t ) => {
417+ t . throws (
418+ ( ) =>
419+ dbConfig . parseUserConfig (
420+ "test" ,
421+ `
422+ paths-ignore:
423+ - "some/path"
424+ queries:
425+ - foo
426+ ` ,
427+ ) ,
428+ {
429+ instanceOf : ConfigurationError ,
430+ } ,
431+ ) ;
432+ } ) ;
0 commit comments