Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7c950eb

Browse filesBrowse files
committed
Add more tests
1 parent 1259541 commit 7c950eb
Copy full SHA for 7c950eb

File tree

Expand file treeCollapse file tree

2 files changed

+44
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+44
-0
lines changed

‎__tests__/cache-save.test.ts

Copy file name to clipboardExpand all lines: __tests__/cache-save.test.ts
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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(() => {

‎__tests__/data/.tool-versions

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python 3.7.12

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.