Skip to content

Commit 2c7a487

Browse files
Merge pull request #350 from e-korolevskii/Add-tests-for-updated-cachetool-ver-(347)
test(cache): Add test for cachetool v 3.0
2 parents 2dfaeac + e2f30c1 commit 2c7a487

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

__tests__/cache.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,27 @@ describe('dependency cache', () => {
153153
return expect(save('ant')).rejects.toThrowError('unknown package manager specified: ant');
154154
});
155155

156+
it('save with -1 cacheId , should not fail workflow', async () => {
157+
spyCacheSave.mockImplementation(() => Promise.resolve(-1));
158+
createStateForMissingBuildFile();
159+
160+
await save('maven');
161+
expect(spyCacheSave).toBeCalled();
162+
expect(spyWarning).not.toBeCalled();
163+
expect(spyInfo).toBeCalled();
164+
expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/));
165+
});
166+
167+
it('saves with error from toolkit, should fail workflow', async () => {
168+
spyCacheSave.mockImplementation(() =>
169+
Promise.reject(new cache.ValidationError('Validation failed'))
170+
);
171+
createStateForMissingBuildFile();
172+
173+
expect.assertions(1);
174+
await expect(save('maven')).rejects.toEqual(new cache.ValidationError('Validation failed'));
175+
});
176+
156177
describe('for maven', () => {
157178
it('uploads cache even if no pom.xml found', async () => {
158179
createStateForMissingBuildFile();

0 commit comments

Comments
 (0)