@@ -27,6 +27,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
2727 let debugSpy : jest . SpyInstance ;
2828 let saveSatetSpy : jest . SpyInstance ;
2929 let getStateSpy : jest . SpyInstance ;
30+ let setOutputSpy : jest . SpyInstance ;
3031
3132 // cache spy
3233 let restoreCacheSpy : jest . SpyInstance ;
@@ -64,6 +65,9 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
6465 return { stdout : '' , stderr : 'Error occured' , exitCode : 2 } ;
6566 } ) ;
6667
68+ setOutputSpy = jest . spyOn ( core , 'setOutput' ) ;
69+ setOutputSpy . mockImplementation ( input => undefined ) ;
70+
6771 restoreCacheSpy = jest . spyOn ( cache , 'restoreCache' ) ;
6872 restoreCacheSpy . mockImplementation (
6973 ( cachePaths : string [ ] , primaryKey : string , restoreKey ?: string ) => {
@@ -100,7 +104,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
100104 ] ) (
101105 'restored dependencies for %s by primaryKey' ,
102106 async ( packageManager , pythonVersion , dependencyFile , fileHash ) => {
103- const cacheDistributor = await getCacheDistributor (
107+ const cacheDistributor = getCacheDistributor (
104108 packageManager ,
105109 pythonVersion ,
106110 dependencyFile
@@ -126,7 +130,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
126130 dependencyFile ,
127131 cacheDependencyPath
128132 ) => {
129- const cacheDistributor = await getCacheDistributor (
133+ const cacheDistributor = getCacheDistributor (
130134 packageManager ,
131135 pythonVersion ,
132136 dependencyFile
@@ -162,7 +166,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
162166 return primaryKey !== fileHash && restoreKey ? pipFileLockHash : '' ;
163167 }
164168 ) ;
165- const cacheDistributor = await getCacheDistributor (
169+ const cacheDistributor = getCacheDistributor (
166170 packageManager ,
167171 pythonVersion ,
168172 dependencyFile
@@ -187,6 +191,38 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
187191 ) ;
188192 } ) ;
189193
194+ describe ( 'Check if handleMatchResult' , ( ) => {
195+ it . each ( [
196+ [ 'pip' , '3.8.12' , 'requirements.txt' , 'someKey' , 'someKey' , true ] ,
197+ [ 'pipenv' , '3.9.1' , 'requirements.txt' , 'someKey' , 'someKey' , true ] ,
198+ [ 'poetry' , '3.8.12' , 'requirements.txt' , 'someKey' , 'someKey' , true ] ,
199+ [ 'pip' , '3.9.2' , 'requirements.txt' , undefined , 'someKey' , false ] ,
200+ [ 'pipenv' , '3.8.12' , 'requirements.txt' , undefined , 'someKey' , false ] ,
201+ [ 'poetry' , '3.9.12' , 'requirements.txt' , undefined , 'someKey' , false ]
202+ ] ) (
203+ 'sets correct outputs' ,
204+ async (
205+ packageManager ,
206+ pythonVersion ,
207+ dependencyFile ,
208+ matchedKey ,
209+ restoredKey ,
210+ expectedOutputValue
211+ ) => {
212+ const cacheDistributor = getCacheDistributor (
213+ packageManager ,
214+ pythonVersion ,
215+ dependencyFile
216+ ) ;
217+ cacheDistributor . handleMatchResult ( matchedKey , restoredKey ) ;
218+ expect ( setOutputSpy ) . toHaveBeenCalledWith (
219+ 'cache-hit' ,
220+ expectedOutputValue
221+ ) ;
222+ }
223+ ) ;
224+ } ) ;
225+
190226 afterEach ( ( ) => {
191227 jest . resetAllMocks ( ) ;
192228 jest . clearAllMocks ( ) ;
0 commit comments