mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-26 04:16:18 +08:00
626d937994
Commas are explicitly disallowed in cache keys, so remove any from workflow name when generating cache key.
27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
import * as cacheUtils from '../../src/cache-utils'
|
|
|
|
describe('cacheUtils-utils', () => {
|
|
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')
|
|
})
|
|
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)
|
|
})
|
|
})
|
|
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')
|
|
})
|
|
})
|
|
})
|