@@ -708,10 +708,6 @@ describe('zip-it-and-ship-it', () => {
708708 } )
709709 } )
710710
711- testMany ( 'Throws when the source folder does not exist' , [ ...allBundleConfigs , 'bundler_none' ] , async ( options ) => {
712- await expect ( zipNode ( 'does-not-exist' , { opts : options } ) ) . rejects . toThrowError ( / F u n c t i o n s f o l d e r s d o n o t e x i s t / )
713- } )
714-
715711 testMany (
716712 'Works even if destination folder does not exist' ,
717713 [ ...allBundleConfigs , 'bundler_none' ] ,
@@ -3059,3 +3055,59 @@ test('Supports functions inside the plugins modules path', async () => {
30593055
30603056 await tmpDir . cleanup ( )
30613057} )
3058+
3059+ test ( 'Supports individual functions even when none of the given function directories exist' , async ( ) => {
3060+ const tmpDir = await getTmpDir ( {
3061+ // Cleanup the folder even if there are still files in them
3062+ unsafeCleanup : true ,
3063+ } )
3064+ const basePath = join ( FIXTURES_ESM_DIR , 'v2-api-files-and-directories' )
3065+ const files = await zipFunctions (
3066+ {
3067+ generated : {
3068+ directories : [ join ( basePath , 'does-not-exist/functions' ) ] ,
3069+ functions : [
3070+ join ( basePath , 'cat.jpg' ) ,
3071+ join ( basePath , 'func2.mjs' ) ,
3072+ join ( basePath , 'func3' ) ,
3073+ join ( basePath , 'func4' ) ,
3074+ ] ,
3075+ } ,
3076+ user : {
3077+ directories : [ join ( basePath , 'does-not-exist-either/functions' ) ] ,
3078+ } ,
3079+ } ,
3080+ tmpDir . path ,
3081+ {
3082+ basePath,
3083+ } ,
3084+ )
3085+
3086+ expect ( files . length ) . toBe ( 3 )
3087+
3088+ const unzippedFunctions = await unzipFiles ( files )
3089+ const functions = getFunctionResultsByName ( unzippedFunctions )
3090+
3091+ const func2 = await importFunctionFile ( `${ tmpDir . path } /${ functions . func2 . name } /${ functions . func2 . entryFilename } ` )
3092+ const func2Result = await invokeLambda ( func2 )
3093+ expect ( func2Result . statusCode ) . toBe ( 200 )
3094+ expect ( await readAsBuffer ( func2Result . body ) ) . toStrictEqual (
3095+ JSON . stringify ( { func : 2 , mod3 : 'module-3' , mod4 : 'module-4' } ) ,
3096+ )
3097+
3098+ const func3 = await importFunctionFile ( `${ tmpDir . path } /${ functions . func3 . name } /${ functions . func3 . entryFilename } ` )
3099+ const func3Result = await invokeLambda ( func3 )
3100+ expect ( func3Result . statusCode ) . toBe ( 200 )
3101+ expect ( await readAsBuffer ( func3Result . body ) ) . toStrictEqual (
3102+ JSON . stringify ( { func : 3 , mod3 : 'module-3' , mod4 : 'module-4' } ) ,
3103+ )
3104+
3105+ const func4 = await importFunctionFile ( `${ tmpDir . path } /${ functions . func4 . name } /${ functions . func4 . entryFilename } ` )
3106+ const func4Result = await invokeLambda ( func4 )
3107+ expect ( func4Result . statusCode ) . toBe ( 200 )
3108+ expect ( await readAsBuffer ( func4Result . body ) ) . toStrictEqual (
3109+ JSON . stringify ( { func : 4 , mod3 : 'module-3' , mod4 : 'module-4' } ) ,
3110+ )
3111+
3112+ await tmpDir . cleanup ( )
3113+ } )
0 commit comments