Skip to content

Commit

Permalink
Merge pull request #350 from e-korolevskii/Add-tests-for-updated-cach…
Browse files Browse the repository at this point in the history
…etool-ver-(347)

test(cache): Add test for cachetool v 3.0
  • Loading branch information
marko-zivic-93 authored Jul 6, 2022
2 parents 2dfaeac + e2f30c1 commit 2c7a487
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions __tests__/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,27 @@ describe('dependency cache', () => {
return expect(save('ant')).rejects.toThrowError('unknown package manager specified: ant');
});

it('save with -1 cacheId , should not fail workflow', async () => {
spyCacheSave.mockImplementation(() => Promise.resolve(-1));
createStateForMissingBuildFile();

await save('maven');
expect(spyCacheSave).toBeCalled();
expect(spyWarning).not.toBeCalled();
expect(spyInfo).toBeCalled();
expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/));
});

it('saves with error from toolkit, should fail workflow', async () => {
spyCacheSave.mockImplementation(() =>
Promise.reject(new cache.ValidationError('Validation failed'))
);
createStateForMissingBuildFile();

expect.assertions(1);
await expect(save('maven')).rejects.toEqual(new cache.ValidationError('Validation failed'));
});

describe('for maven', () => {
it('uploads cache even if no pom.xml found', async () => {
createStateForMissingBuildFile();
Expand Down

0 comments on commit 2c7a487

Please # to comment.