Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(cache): Add test for cachetool v 3.0 #350

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions __tests__/cache.test.ts
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