@@ -11,6 +11,7 @@ describe('run', () => {
1111 'd8110e0006d7fb5ee76365d565eef9d37df1d11598b912d3eb66d398d57a1121' ;
1212 const requirementsLinuxHash =
1313 '2d0ff7f46b0e120e3d3294db65768b474934242637b9899b873e6283dfd16d7c' ;
14+ const poetryLockHash = '571bf984f8d210e6a97f854e479fdd4a2b5af67b5fdac109ec337a0ea16e7836' ;
1415
1516 // core spy
1617 let infoSpy : jest . SpyInstance ;
@@ -114,6 +115,22 @@ describe('run', () => {
114115 ) ;
115116 expect ( setFailedSpy ) . not . toHaveBeenCalled ( ) ;
116117 } ) ;
118+
119+ it ( 'should not save cache for pipenv' , async ( ) => {
120+ inputs [ 'cache' ] = 'pipenv' ;
121+
122+ await run ( ) ;
123+
124+ expect ( getInputSpy ) . toHaveBeenCalled ( ) ;
125+ expect ( debugSpy ) . toHaveBeenCalledWith (
126+ `paths for caching are ${ __dirname } `
127+ ) ;
128+ expect ( getStateSpy ) . toHaveBeenCalledTimes ( 3 ) ;
129+ expect ( infoSpy ) . toHaveBeenCalledWith (
130+ `Cache hit occurred on the primary key ${ requirementsHash } , not saving cache.`
131+ ) ;
132+ expect ( setFailedSpy ) . not . toHaveBeenCalled ( ) ;
133+ } ) ;
117134 } ) ;
118135
119136 describe ( 'action saves the cache' , ( ) => {
@@ -168,6 +185,32 @@ describe('run', () => {
168185 ) ;
169186 expect ( setFailedSpy ) . not . toHaveBeenCalled ( ) ;
170187 } ) ;
188+
189+ it ( 'saves cache from poetry' , async ( ) => {
190+ inputs [ 'cache' ] = 'poetry' ;
191+ getStateSpy . mockImplementation ( ( name : string ) => {
192+ if ( name === State . CACHE_MATCHED_KEY ) {
193+ return poetryLockHash ;
194+ } else if ( name === State . CACHE_PATHS ) {
195+ return JSON . stringify ( [ __dirname ] ) ;
196+ } else {
197+ return requirementsHash ;
198+ }
199+ } ) ;
200+
201+ await run ( ) ;
202+
203+ expect ( getInputSpy ) . toHaveBeenCalled ( ) ;
204+ expect ( getStateSpy ) . toHaveBeenCalledTimes ( 3 ) ;
205+ expect ( infoSpy ) . not . toHaveBeenCalledWith (
206+ `Cache hit occurred on the primary key ${ poetryLockHash } , not saving cache.`
207+ ) ;
208+ expect ( saveCacheSpy ) . toHaveBeenCalled ( ) ;
209+ expect ( infoSpy ) . toHaveBeenLastCalledWith (
210+ `Cache saved with the key: ${ requirementsHash } `
211+ ) ;
212+ expect ( setFailedSpy ) . not . toHaveBeenCalled ( ) ;
213+ } ) ;
171214 } ) ;
172215
173216 afterEach ( ( ) => {
0 commit comments