@@ -375,6 +375,112 @@ tests['getenv.array() nonexistent type'] = function() {
375375 } ) ;
376376} ;
377377
378+ tests [ 'getenv.multi([string]) multiple env vars' ] = function ( ) {
379+ var spec = {
380+ foo : 'TEST_GETENV_STRING' // throws when nonexistant
381+ } ;
382+ var config = getenv . multi ( spec ) ;
383+ var expect = {
384+ foo : process . env . TEST_GETENV_STRING
385+ } ;
386+ assert . deepEqual ( expect , config ) ;
387+ } ;
388+
389+ tests [ 'getenv([string]) multiple env vars shortcut' ] = function ( ) {
390+ var spec = {
391+ foo : 'TEST_GETENV_STRING' // throws when nonexistant
392+ } ;
393+ var config = getenv ( spec ) ;
394+ var expect = {
395+ foo : process . env . TEST_GETENV_STRING
396+ } ;
397+ assert . deepEqual ( expect , config ) ;
398+ } ;
399+
400+
401+ tests [ 'getenv.multi([string/throw]) multiple env vars' ] = function ( ) {
402+ var spec = {
403+ foo : 'TEST_GETENV_NONEXISTENT' // throws when nonexistant
404+ } ;
405+ assert . throws ( function ( ) {
406+ var config = getenv . multi ( spec ) ;
407+ } ) ;
408+ } ;
409+
410+ tests [ 'getenv.multi([string/typecast]) multiple env vars' ] = function ( ) {
411+ var spec = {
412+ foo : [ 'TEST_GETENV_STRING' , undefined , 'string' ]
413+ } ;
414+ var config = getenv . multi ( spec ) ;
415+ var expect = {
416+ foo : process . env . TEST_GETENV_STRING
417+ } ;
418+ assert . deepEqual ( expect , config ) ;
419+ } ;
420+
421+ tests [ 'getenv.multi([string/typecast/defaultval]) multiple env vars' ] = function ( ) {
422+ var spec = {
423+ foo : [ 'TEST_GETENV_NONEXISTENT' , 'default' , 'string' ] // throws when nonexistant
424+ } ;
425+ var config = getenv . multi ( spec ) ;
426+ var expect = {
427+ foo : 'default'
428+ } ;
429+ assert . deepEqual ( expect , config ) ;
430+ } ;
431+
432+ tests [ 'getenv.multi([string/typecast/throw]) multiple env vars' ] = function ( ) {
433+ var spec = {
434+ foo : [ 'TEST_GETENV_NONEXISTENT' , undefined , 'string' ] // throws when nonexistant
435+ } ;
436+ assert . throws ( function ( ) {
437+ var config = getenv . multi ( spec ) ;
438+ } ) ;
439+ } ;
440+
441+ tests [ 'getenv.multi([string/defaultval]) multiple env vars' ] = function ( ) {
442+ var spec = {
443+ foo : [ 'TEST_GETENV_STRING' , 'default' ] // throws when nonexistant
444+ } ;
445+ var config = getenv . multi ( spec ) ;
446+ var expect = {
447+ foo : process . env . TEST_GETENV_STRING
448+ } ;
449+ assert . deepEqual ( expect , config ) ;
450+ } ;
451+
452+ tests [ 'getenv.multi([string/defaultval/throw]) multiple env vars' ] = function ( ) {
453+ var spec = {
454+ foo : [ 'TEST_GETENV_NONEXISTENT' , 'default' ] // throws when nonexistant
455+ } ;
456+ var config = getenv . multi ( spec ) ;
457+ var expect = {
458+ foo : 'default'
459+ } ;
460+ assert . deepEqual ( expect , config ) ;
461+ } ;
462+
463+ tests [ 'getenv.multi([string/single]) multiple env vars' ] = function ( ) {
464+ var spec = {
465+ foo : [ 'TEST_GETENV_STRING' ] // throws when nonexistant
466+ } ;
467+ var config = getenv . multi ( spec ) ;
468+ var expect = {
469+ foo : process . env . TEST_GETENV_STRING
470+ } ;
471+ assert . deepEqual ( expect , config ) ;
472+ } ;
473+
474+ tests [ 'getenv.multi([string/single/throw]) multiple env vars' ] = function ( ) {
475+ var spec = {
476+ foo : [ 'TEST_GETENV_NONEXISTENT' ] // throws when nonexistant
477+ } ;
478+ assert . throws ( function ( ) {
479+ var config = getenv . multi ( spec ) ;
480+ } ) ;
481+ } ;
482+
483+
378484Object . keys ( tests ) . forEach ( function ( key ) {
379485 console . log ( 'Test: %s' , key ) ;
380486 tests [ key ] ( ) ;
0 commit comments