Cache fallback with rolling time based expiration

This commit is contained in:
Pelle Wessman 2024-03-13 21:15:09 +01:00
parent c2ac33f2c6
commit f01118b9a5
No known key found for this signature in database
6 changed files with 40 additions and 17 deletions

View file

@ -132,13 +132,13 @@ describe('cache-restore', () => {
}
});
await restoreCache(packageManager, '');
await restoreCache(packageManager, '', '0');
expect(hashFilesSpy).toHaveBeenCalled();
expect(infoSpy).toHaveBeenCalledWith(
`Cache restored from key: node-cache-${platform}-${packageManager}-${fileHash}`
`Cache restored from key: ${platform}-0-setup-node-${packageManager}-${fileHash}`
);
expect(infoSpy).not.toHaveBeenCalledWith(
`${packageManager} cache is not found`
`Cache not found for input keys: ${platform}-0-setup-node-${packageManager}-${fileHash}, ${platform}-0-setup-node-${packageManager}-`
);
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
}
@ -163,10 +163,10 @@ describe('cache-restore', () => {
});
restoreCacheSpy.mockImplementationOnce(() => undefined);
await restoreCache(packageManager, '');
await restoreCache(packageManager, '', '0');
expect(hashFilesSpy).toHaveBeenCalled();
expect(infoSpy).toHaveBeenCalledWith(
`${packageManager} cache is not found`
`Cache not found for input keys: ${platform}-0-setup-node-${packageManager}-${fileHash}, ${platform}-0-setup-node-${packageManager}-`
);
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', false);
}