Skip to content

Commit

Permalink
Merge pull request #448 from IvanZosimov/CacheLibVersionUpdate
Browse files Browse the repository at this point in the history
Add support for the @actions/cache library 3.0.0
  • Loading branch information
marko-zivic-93 committed Jun 30, 2022
2 parents ab6deb3 + 41b9110 commit 5407bf6
Show file tree
Hide file tree
Showing 9 changed files with 1,781 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .licenses/npm/@actions/cache.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions .licenses/npm/@actions/http-client-1.0.11.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions .licenses/npm/@actions/http-client-2.0.1.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions __tests__/cache-save.test.ts
Expand Up @@ -212,6 +212,59 @@ describe('run', () => {
);
expect(setFailedSpy).not.toHaveBeenCalled();
});

it('saves with -1 cacheId , should not fail workflow', async () => {
inputs['cache'] = 'poetry';
getStateSpy.mockImplementation((name: string) => {
if (name === State.STATE_CACHE_PRIMARY_KEY) {
return poetryLockHash;
} else if (name === State.CACHE_PATHS) {
return JSON.stringify([__dirname]);
} else {
return requirementsHash;
}
});

saveCacheSpy.mockImplementation(() => {
return -1;
});

await run();

expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(infoSpy).not.toHaveBeenCalled();
expect(saveCacheSpy).toHaveBeenCalled();
expect(infoSpy).not.toHaveBeenLastCalledWith(
`Cache saved with the key: ${poetryLockHash}`
);
expect(setFailedSpy).not.toHaveBeenCalled();
});

it('saves with error from toolkit, should fail workflow', async () => {
inputs['cache'] = 'npm';
getStateSpy.mockImplementation((name: string) => {
if (name === State.STATE_CACHE_PRIMARY_KEY) {
return poetryLockHash;
} else if (name === State.CACHE_PATHS) {
return JSON.stringify([__dirname]);
} else {
return requirementsHash;
}
});

saveCacheSpy.mockImplementation(() => {
throw new cache.ValidationError('Validation failed');
});

await run();

expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(infoSpy).not.toHaveBeenCalledWith();
expect(saveCacheSpy).toHaveBeenCalled();
expect(setFailedSpy).toHaveBeenCalled();
});
});

afterEach(() => {
Expand Down

0 comments on commit 5407bf6

Please sign in to comment.