2022-06-11 11:39:18 -04:00
|
|
|
import * as cacheUtils from '../../src/cache-utils'
|
2020-06-15 06:59:55 -04:00
|
|
|
|
2021-08-24 14:46:48 -04:00
|
|
|
describe('cacheUtils-utils', () => {
|
2021-09-05 23:35:17 -04:00
|
|
|
describe('can hash', () => {
|
|
|
|
it('a string', async () => {
|
|
|
|
const hash = cacheUtils.hashStrings(['foo'])
|
|
|
|
expect(hash).toBe('acbd18db4cc2f85cedef654fccc4a4d8')
|
|
|
|
})
|
|
|
|
it('multiple strings', async () => {
|
|
|
|
const hash = cacheUtils.hashStrings(['foo', 'bar', 'baz'])
|
|
|
|
expect(hash).toBe('6df23dc03f9b54cc38a0fc1483df6e21')
|
2021-08-24 14:46:48 -04:00
|
|
|
})
|
2021-09-27 23:05:17 -04:00
|
|
|
it('normalized filenames', async () => {
|
|
|
|
const fileNames = ['/foo/bar/baz.zip', '../boo.html']
|
|
|
|
const posixHash = cacheUtils.hashFileNames(fileNames)
|
|
|
|
const windowsHash = cacheUtils.hashFileNames(fileNames)
|
|
|
|
expect(posixHash).toBe(windowsHash)
|
|
|
|
})
|
2021-08-24 14:46:48 -04:00
|
|
|
})
|
2023-06-29 12:01:14 -04:00
|
|
|
describe('sanitizes workflow name in cache key', () => {
|
|
|
|
it('with comma', () => {
|
|
|
|
const cacheKey = cacheUtils.getCacheKeyForJob("Workflow, with,commas", "JOB_ID")
|
|
|
|
expect(cacheKey).toBe('workflow withcommas-JOB_ID')
|
|
|
|
})
|
|
|
|
})
|
2020-06-15 06:59:55 -04:00
|
|
|
})
|