@@ -200,7 +200,7 @@ describe('inject-collector-cache-config-extension', () => {
200200 expect ( fs . existsSync ( zipFileName ) ) . to . eql ( true )
201201 } )
202202
203- it ( 'cache not found multiple scans ' , async ( ) => {
203+ it ( 'cache not with multiple scan [{ scan: { dir: }, { scan: dir: } ] ' , async ( ) => {
204204 const tag = createTag ( '1.0.0' )
205205 tag . origins [ 0 ] . refhash = tag . origins [ 0 ] . refhash . split ( '' ) . reverse ( ) . join ( '' )
206206 // make multiple scan dirs
@@ -255,6 +255,63 @@ describe('inject-collector-cache-config-extension', () => {
255255 await generatorContext . beforePublish ( )
256256 expect ( fs . existsSync ( zipFileName ) ) . to . eql ( true )
257257 } )
258+
259+ it ( 'cache not found with multiple scan dirs { run: , scan [ { dir: }, { dir: } ] }' , async ( ) => {
260+ const tag = createTag ( '1.0.0' )
261+ tag . origins [ 0 ] . refhash = tag . origins [ 0 ] . refhash . split ( '' ) . reverse ( ) . join ( '' )
262+ // make multiple scan dirs
263+ tag . origins [ 0 ] . descriptor = {
264+ ext : {
265+ collector : [
266+ {
267+ run : { command : './mvnw -B validate process-resources dependency:unpack -am -Pantora-process-resources' } ,
268+ scan : [ { dir : 'target/classes/antora-resources/' } , { dir : 'target/antora/' } ] ,
269+ } ,
270+ ] ,
271+ } ,
272+ }
273+ contentAggregate = [ tag ]
274+ ext . register . call ( generatorContext , { playbook } )
275+ await generatorContext . contentAggregated ( { playbook, contentAggregate } )
276+ expect ( fs . existsSync ( ospath . join ( cacheDir , 'collector-cache/spring-security' ) ) ) . to . equal ( true )
277+ const actual = contentAggregate [ 0 ] . origins [ 0 ] . descriptor . ext
278+ const scan = ospath . join ( cacheDir , 'collector/spring-security/target/classes/antora-resources' )
279+ const scan2 = ospath . join ( cacheDir , 'collector/spring-security/target/antora' )
280+ const cache = ospath . join ( cacheDir , 'collector-cache/spring-security/2c4fb2f-1.0.0' )
281+ const zipFileName = ospath . join (
282+ playbookDir ,
283+ 'build/antora/inject-collector-cache-config-extension/.cache/2c4fb2f-1.0.0.zip'
284+ )
285+ const expected = {
286+ collector : [
287+ {
288+ run : {
289+ command : './mvnw -B validate process-resources dependency:unpack -am -Pantora-process-resources' ,
290+ } ,
291+ scan : [ { dir : 'target/classes/antora-resources/' } , { dir : 'target/antora/' } ] ,
292+ } ,
293+ {
294+ run : {
295+ command : `node '${ resolvedCacheScanDirIndexJs } ' '${ scan } ' '${ cache } '` ,
296+ } ,
297+ } ,
298+ {
299+ run : {
300+ command : `node '${ resolvedCacheScanDirIndexJs } ' '${ scan2 } ' '${ cache } '` ,
301+ } ,
302+ } ,
303+ ] ,
304+ }
305+ expect ( actual ) . to . eql ( expected )
306+ expect ( generatorContext . messages ) . to . eql ( [
307+ `Unable to restore cache from ${ httpServerUrl } /.cache/2c4fb2f-1.0.0.zip` ,
308+ `Configuring collector to cache '${ scan } ' at '${ cache } '` ,
309+ `Configuring collector to cache '${ scan2 } ' at '${ cache } '` ,
310+ ] )
311+ expect ( fs . existsSync ( zipFileName ) ) . to . eql ( false )
312+ await generatorContext . beforePublish ( )
313+ expect ( fs . existsSync ( zipFileName ) ) . to . eql ( true )
314+ } )
258315 it ( 'cache downloaded' , async ( ) => {
259316 const zipFileName = ospath . join (
260317 playbookDir ,
0 commit comments