mirror of
https://github.com/actions/setup-node.git
synced 2026-02-14 01:14:48 +08:00
Add cache-key as output
This commit is contained in:
@@ -27,6 +27,7 @@ describe('run', () => {
|
||||
let setFailedSpy: jest.SpyInstance;
|
||||
let getStateSpy: jest.SpyInstance;
|
||||
let saveCacheSpy: jest.SpyInstance;
|
||||
let setOutputSpy: jest.SpyInstance;
|
||||
let getCommandOutputSpy: jest.SpyInstance;
|
||||
let hashFilesSpy: jest.SpyInstance;
|
||||
let existsSpy: jest.SpyInstance;
|
||||
@@ -53,6 +54,8 @@ describe('run', () => {
|
||||
saveCacheSpy = jest.spyOn(cache, 'saveCache');
|
||||
saveCacheSpy.mockImplementation(() => undefined);
|
||||
|
||||
setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||
|
||||
// glob
|
||||
hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
||||
hashFilesSpy.mockImplementation((pattern: string) => {
|
||||
@@ -228,6 +231,7 @@ describe('run', () => {
|
||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||
`Cache saved with the key: ${npmFileHash}`
|
||||
);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('cache-key', npmFileHash);
|
||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -258,6 +262,7 @@ describe('run', () => {
|
||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||
`Cache saved with the key: ${npmFileHash}`
|
||||
);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('cache-key', npmFileHash);
|
||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -288,6 +293,7 @@ describe('run', () => {
|
||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||
`Cache saved with the key: ${yarnFileHash}`
|
||||
);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('cache-key', yarnFileHash);
|
||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -297,9 +303,9 @@ describe('run', () => {
|
||||
key === State.CachePackageManager
|
||||
? inputs['cache']
|
||||
: key === State.CacheMatchedKey
|
||||
? pnpmFileHash
|
||||
? 'no-match'
|
||||
: key === State.CachePrimaryKey
|
||||
? npmFileHash
|
||||
? pnpmFileHash
|
||||
: key === State.CachePaths
|
||||
? '["/foo/bar"]'
|
||||
: 'not expected'
|
||||
@@ -316,8 +322,9 @@ describe('run', () => {
|
||||
);
|
||||
expect(saveCacheSpy).toHaveBeenCalled();
|
||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||
`Cache saved with the key: ${npmFileHash}`
|
||||
`Cache saved with the key: ${pnpmFileHash}`
|
||||
);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('cache-key', pnpmFileHash);
|
||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user