@@ -11,6 +11,7 @@ describe('run', () => {
11
11
'd8110e0006d7fb5ee76365d565eef9d37df1d11598b912d3eb66d398d57a1121' ;
12
12
const requirementsLinuxHash =
13
13
'2d0ff7f46b0e120e3d3294db65768b474934242637b9899b873e6283dfd16d7c' ;
14
+ const poetryLockHash = '571bf984f8d210e6a97f854e479fdd4a2b5af67b5fdac109ec337a0ea16e7836' ;
14
15
15
16
// core spy
16
17
let infoSpy : jest . SpyInstance ;
@@ -114,6 +115,22 @@ describe('run', () => {
114
115
) ;
115
116
expect ( setFailedSpy ) . not . toHaveBeenCalled ( ) ;
116
117
} ) ;
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
+ } ) ;
117
134
} ) ;
118
135
119
136
describe ( 'action saves the cache' , ( ) => {
@@ -168,6 +185,32 @@ describe('run', () => {
168
185
) ;
169
186
expect ( setFailedSpy ) . not . toHaveBeenCalled ( ) ;
170
187
} ) ;
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
+ } ) ;
171
214
} ) ;
172
215
173
216
afterEach ( ( ) => {
0 commit comments