@@ -114,20 +114,46 @@ describe('linux toolchain installation verification', () => {
114114    } 
115115  ) 
116116
117-   it ( 'tests installation with cache' ,  async  ( )  =>  { 
117+   it ( 'tests installation with action cache' ,  async  ( )  =>  { 
118+     const  installer  =  new  LinuxToolchainInstaller ( toolchain ) 
119+     const  cached  =  path . resolve ( 'tool' ,  'cached' ,  'path' ) 
120+     const  swiftPath  =  path . join ( cached ,  'usr' ,  'bin' ) 
121+     jest . spyOn ( toolCache ,  'find' ) . mockReturnValue ( '' ) 
122+     jest . spyOn ( cache ,  'restoreCache' ) . mockResolvedValue ( cached ) 
123+     jest . spyOn ( core ,  'getBooleanInput' ) . mockReturnValue ( true ) 
124+     jest . spyOn ( exec ,  'exec' ) . mockResolvedValue ( 0 ) 
125+     const  downloadSpy  =  jest . spyOn ( toolCache ,  'downloadTool' ) 
126+     const  extractSpy  =  jest . spyOn ( toolCache ,  'extractTar' ) 
127+     const  toolCacheSpy  =  jest . spyOn ( toolCache ,  'cacheDir' ) 
128+     const  actionCacheSpy  =  jest . spyOn ( cache ,  'saveCache' ) 
129+     toolCacheSpy . mockResolvedValue ( cached ) 
130+     await  installer . install ( 'aarch64' ) 
131+     const  toolCacheKey  =  `${ toolchain . dir } ${ toolchain . platform }  
132+     const  tmpDir  =  process . env . RUNNER_TEMP  ||  os . tmpdir ( ) 
133+     const  restore  =  path . join ( tmpDir ,  'setup-swift' ,  toolCacheKey ) 
134+     expect ( process . env . PATH ?. includes ( swiftPath ) ) . toBeTruthy ( ) 
135+     expect ( toolCacheSpy . mock . calls [ 0 ] ?. [ 0 ] ) . toBe ( restore ) 
136+     expect ( toolCacheSpy . mock . calls [ 0 ] ?. [ 1 ] ) . toBe ( toolCacheKey ) 
137+     expect ( toolCacheSpy . mock . calls [ 0 ] ?. [ 2 ] ) . toBe ( '5.8.0' ) 
138+     for  ( const  spy  of  [ downloadSpy ,  extractSpy ,  actionCacheSpy ] )  { 
139+       expect ( spy ) . not . toHaveBeenCalled ( ) 
140+     } 
141+   } ) 
142+ 
143+   it ( 'tests installation with tool cache' ,  async  ( )  =>  { 
118144    const  installer  =  new  LinuxToolchainInstaller ( toolchain ) 
119145    const  cached  =  path . resolve ( 'tool' ,  'cached' ,  'path' ) 
120146    const  swiftPath  =  path . join ( cached ,  'usr' ,  'bin' ) 
121147    jest . spyOn ( toolCache ,  'find' ) . mockReturnValue ( cached ) 
122-     jest . spyOn ( toolCache ,  'cacheDir' ) . mockResolvedValue ( cached ) 
123-     jest . spyOn ( cache ,  'saveCache' ) . mockResolvedValue ( 1 ) 
124148    jest . spyOn ( core ,  'getBooleanInput' ) . mockReturnValue ( true ) 
125149    jest . spyOn ( exec ,  'exec' ) . mockResolvedValue ( 0 ) 
126150    const  downloadSpy  =  jest . spyOn ( toolCache ,  'downloadTool' ) 
127151    const  extractSpy  =  jest . spyOn ( toolCache ,  'extractTar' ) 
152+     const  toolCacheSpy  =  jest . spyOn ( toolCache ,  'cacheDir' ) 
153+     const  actionCacheSpy  =  jest . spyOn ( cache ,  'saveCache' ) 
128154    await  installer . install ( 'aarch64' ) 
129155    expect ( process . env . PATH ?. includes ( swiftPath ) ) . toBeTruthy ( ) 
130-     for  ( const  spy  of  [ downloadSpy ,  extractSpy ] )  { 
156+     for  ( const  spy  of  [ downloadSpy ,  extractSpy ,   toolCacheSpy ,   actionCacheSpy ] )  { 
131157      expect ( spy ) . not . toHaveBeenCalled ( ) 
132158    } 
133159  } ) 
0 commit comments