@@ -828,6 +828,82 @@ describe.skipIf(lt(denoVersion, '2.4.3'))(
828828 await cleanup ( )
829829 await rm ( vendorDirectory . path , { force : true , recursive : true } )
830830 } )
831+
832+ describe ( 'Dry-run tarball generation flag enabled' , ( ) => {
833+ test ( 'Logs success message when tarball generation succeeded' , async ( ) => {
834+ const systemLogger = vi . fn ( )
835+ const { basePath, cleanup, distPath } = await useFixture ( 'imports_node_builtin' , { copyDirectory : true } )
836+ const declarations : Declaration [ ] = [
837+ {
838+ function : 'func1' ,
839+ path : '/func1' ,
840+ } ,
841+ ]
842+
843+ await bundle ( [ join ( basePath , 'netlify/edge-functions' ) ] , distPath , declarations , {
844+ basePath,
845+ configPath : join ( basePath , '.netlify/edge-functions/config.json' ) ,
846+ featureFlags : {
847+ edge_bundler_dry_run_generate_tarball : true ,
848+ edge_bundler_generate_tarball : false ,
849+ } ,
850+ systemLogger,
851+ } )
852+
853+ expect ( systemLogger ) . toHaveBeenCalledWith ( 'Dry run: Tarball bundle generated successfully.' )
854+
855+ const manifestFile = await readFile ( resolve ( distPath , 'manifest.json' ) , 'utf8' )
856+ const manifest = JSON . parse ( manifestFile )
857+
858+ expect ( manifest . bundles . length ) . toBe ( 1 )
859+ expect ( manifest . bundles [ 0 ] . format ) . toBe ( 'eszip2' )
860+
861+ await cleanup ( )
862+ } )
863+
864+ test ( 'Logs error message when tarball generation failed and does not fail the overall build' , async ( ) => {
865+ const systemLogger = vi . fn ( )
866+ vi . resetModules ( )
867+ vi . doMock ( './formats/tarball.js' , ( ) => ( {
868+ bundle : vi . fn ( ) . mockRejectedValue ( new Error ( 'Simulated tarball bundling failure' ) ) ,
869+ } ) )
870+
871+ const { bundle : bundleUnderTest } = await import ( './bundler.js' )
872+
873+ const { basePath, cleanup, distPath } = await useFixture ( 'imports_node_builtin' , { copyDirectory : true } )
874+ const sourceDirectory = join ( basePath , 'functions' )
875+ const declarations : Declaration [ ] = [
876+ {
877+ function : 'func1' ,
878+ path : '/func1' ,
879+ } ,
880+ ]
881+
882+ await expect (
883+ bundleUnderTest ( [ sourceDirectory ] , distPath , declarations , {
884+ basePath,
885+ configPath : join ( sourceDirectory , 'config.json' ) ,
886+ featureFlags : {
887+ edge_bundler_dry_run_generate_tarball : true ,
888+ edge_bundler_generate_tarball : false ,
889+ } ,
890+ systemLogger,
891+ } ) ,
892+ ) . resolves . toBeDefined ( )
893+
894+ expect ( systemLogger ) . toHaveBeenCalledWith (
895+ `Dry run: Tarball bundle generation failed: Simulated tarball bundling failure` ,
896+ )
897+
898+ const manifestFile = await readFile ( resolve ( distPath , 'manifest.json' ) , 'utf8' )
899+ const manifest = JSON . parse ( manifestFile )
900+ expect ( manifest . bundles . length ) . toBe ( 1 )
901+ expect ( manifest . bundles [ 0 ] . format ) . toBe ( 'eszip2' )
902+
903+ await cleanup ( )
904+ vi . resetModules ( )
905+ } )
906+ } )
831907 } ,
832908 10_000 ,
833909)
0 commit comments