@@ -10,6 +10,15 @@ describe('restore-cache', () => {
10
10
'd8110e0006d7fb5ee76365d565eef9d37df1d11598b912d3eb66d398d57a1121' ;
11
11
const requirementsLinuxHash =
12
12
'2d0ff7f46b0e120e3d3294db65768b474934242637b9899b873e6283dfd16d7c' ;
13
+ const poetryLockHash = '571bf984f8d210e6a97f854e479fdd4a2b5af67b5fdac109ec337a0ea16e7836' ;
14
+ const poetryConfigOutput = `
15
+ cache-dir = "/Users/patrick/Library/Caches/pypoetry"
16
+ experimental.new-installer = false
17
+ installer.parallel = true
18
+ virtualenvs.create = true
19
+ virtualenvs.in-project = true
20
+ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/pypoetry/virtualenvs
21
+ ` ;
13
22
14
23
// core spy
15
24
let infoSpy : jest . SpyInstance ;
@@ -47,6 +56,9 @@ describe('restore-cache', () => {
47
56
if ( input . includes ( 'pip' ) ) {
48
57
return { stdout : 'pip' , stderr : '' , exitCode : 0 } ;
49
58
}
59
+ if ( input . includes ( 'poetry' ) ) {
60
+ return { stdout : poetryConfigOutput , stderr : '' , exitCode : 0 } ;
61
+ }
50
62
51
63
return { stdout : '' , stderr : 'Error occured' , exitCode : 2 } ;
52
64
} ) ;
@@ -82,7 +94,8 @@ describe('restore-cache', () => {
82
94
] ,
83
95
[ 'pip' , '3.8.12' , '__tests__/data/requirements.txt' , requirementsHash ] ,
84
96
[ 'pipenv' , '3.9.1' , undefined , pipFileLockHash ] ,
85
- [ 'pipenv' , '3.9.12' , '__tests__/data/requirements.txt' , requirementsHash ]
97
+ [ 'pipenv' , '3.9.12' , '__tests__/data/requirements.txt' , requirementsHash ] ,
98
+ [ 'poetry' , '3.9.1' , undefined , poetryLockHash ]
86
99
] ) (
87
100
'restored dependencies for %s by primaryKey' ,
88
101
async ( packageManager , pythonVersion , dependencyFile , fileHash ) => {
@@ -138,7 +151,8 @@ describe('restore-cache', () => {
138
151
] ,
139
152
[ 'pip' , '3.8.12' , '__tests__/data/requirements.txt' , pipFileLockHash ] ,
140
153
[ 'pipenv' , '3.9.1' , undefined , requirementsHash ] ,
141
- [ 'pipenv' , '3.9.12' , '__tests__/data/requirements.txt' , requirementsHash ]
154
+ [ 'pipenv' , '3.9.12' , '__tests__/data/requirements.txt' , requirementsHash ] ,
155
+ [ 'poetry' , '3.9.1' , undefined , requirementsHash ]
142
156
] ) (
143
157
'restored dependencies for %s by primaryKey' ,
144
158
async ( packageManager , pythonVersion , dependencyFile , fileHash ) => {
@@ -154,10 +168,17 @@ describe('restore-cache', () => {
154
168
) ;
155
169
await cacheDistributor . restoreCache ( ) ;
156
170
let result = '' ;
157
- if ( packageManager !== 'pipenv' ) {
158
- result = `Cache restored from key: ${ fileHash } ` ;
159
- } else {
160
- result = 'pipenv cache is not found' ;
171
+
172
+ switch ( packageManager ) {
173
+ case 'pip' :
174
+ result = `Cache restored from key: ${ fileHash } ` ;
175
+ break ;
176
+ case 'pipenv' :
177
+ result = 'pipenv cache is not found' ;
178
+ break ;
179
+ case 'poetry' :
180
+ result = 'poetry cache is not found' ;
181
+ break ;
161
182
}
162
183
163
184
expect ( infoSpy ) . toHaveBeenCalledWith ( result ) ;
0 commit comments