@@ -61,7 +61,7 @@ async function importTool(tarBuffer: Buffer) {
6161 tarBase64 : tarBuffer . toString ( "base64" ) ,
6262 tarBytes : tarBuffer . byteLength ,
6363 sha256 : crypto . createHash ( "sha256" ) . update ( tarBuffer ) . digest ( "hex" ) ,
64- fileCount : 1 ,
64+ fileCount : 3 ,
6565 } ,
6666 startedAt : Date . now ( ) ,
6767 } ) ) ,
@@ -84,30 +84,42 @@ async function executeDirFetch(module: typeof import("./dir-fetch-tool.js")) {
8484describe ( "dir.fetch archive extraction" , ( ) => {
8585 it ( "extracts a bounded tar and returns the plugin-side manifest" , async ( ) => {
8686 const tarBuffer = await createTarBuffer ( {
87- entries : [ "ok.txt" ] ,
87+ entries : [ "ok.txt" , "nested" ] ,
8888 setup : async ( sourceDir ) => {
8989 await fs . writeFile ( path . join ( sourceDir , "ok.txt" ) , "ok" ) ;
90+ await fs . mkdir ( path . join ( sourceDir , "nested" ) ) ;
91+ await fs . writeFile ( path . join ( sourceDir , "nested" , "also-ok.txt" ) , "also ok" ) ;
9092 } ,
9193 } ) ;
9294 const { appendFileTransferAudit, module, saveMediaBuffer } = await importTool ( tarBuffer ) ;
9395
9496 const result = await executeDirFetch ( module ) ;
9597
9698 expect ( result ) . toMatchObject ( {
99+ content : [ { type : "text" , text : expect . stringContaining ( "Fetched 2 files" ) } ] ,
97100 details : {
98101 path : "/tmp/project" ,
99- fileCount : 1 ,
100- files : [
101- {
102- relPath : "ok.txt" ,
103- size : 2 ,
104- sha256 : crypto . createHash ( "sha256" ) . update ( "ok" ) . digest ( "hex" ) ,
105- } ,
106- ] ,
102+ fileCount : 2 ,
107103 } ,
108104 } ) ;
109- const localPath = ( result . details as { files : Array < { localPath : string } > } ) . files [ 0 ]
110- ?. localPath ;
105+ const files = ( result . details as { files : Array < { relPath : string ; localPath : string } > } )
106+ . files ;
107+ expect ( files ) . toHaveLength ( 2 ) ;
108+ expect ( files ) . toEqual (
109+ expect . arrayContaining ( [
110+ expect . objectContaining ( {
111+ relPath : "ok.txt" ,
112+ size : 2 ,
113+ sha256 : crypto . createHash ( "sha256" ) . update ( "ok" ) . digest ( "hex" ) ,
114+ } ) ,
115+ expect . objectContaining ( {
116+ relPath : path . join ( "nested" , "also-ok.txt" ) ,
117+ size : 7 ,
118+ sha256 : crypto . createHash ( "sha256" ) . update ( "also ok" ) . digest ( "hex" ) ,
119+ } ) ,
120+ ] ) ,
121+ ) ;
122+ const localPath = files . find ( ( file ) => file . relPath === "ok.txt" ) ?. localPath ;
111123 await expect ( fs . readFile ( localPath ! , "utf8" ) ) . resolves . toBe ( "ok" ) ;
112124 expect ( saveMediaBuffer ) . toHaveBeenCalledWith (
113125 tarBuffer ,
0 commit comments