mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2025-08-23 05:29:08 +08:00

* Adds option to download using AzCopy * Bump version number and add release notes * Ensure we use at least v10 * Negate env var so it disables AzCopy * Use Azure storage SDK to download cache * Use same level of parallelism as AzCopy * Fix naming of variable * React to feedback * Bump Node types to Node 12 * Make linter happy * Pass options into restoreCache method * Fix tests * Restructure files and add tests * Add method to get the default download and upload options * Include breaking changes in RELEASES.md Co-authored-by: Josh Gross <joshmgross@github.com>
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import {promises as fs} from 'fs'
|
|
import * as path from 'path'
|
|
import * as cacheUtils from '../src/internal/cacheUtils'
|
|
|
|
test('getArchiveFileSizeIsBytes returns file size', () => {
|
|
const filePath = path.join(__dirname, '__fixtures__', 'helloWorld.txt')
|
|
|
|
const size = cacheUtils.getArchiveFileSizeIsBytes(filePath)
|
|
|
|
expect(size).toBe(11)
|
|
})
|
|
|
|
test('unlinkFile unlinks file', async () => {
|
|
const testDirectory = await fs.mkdtemp('unlinkFileTest')
|
|
const testFile = path.join(testDirectory, 'test.txt')
|
|
await fs.writeFile(testFile, 'hello world')
|
|
|
|
await expect(fs.stat(testFile)).resolves.not.toThrow()
|
|
|
|
await cacheUtils.unlinkFile(testFile)
|
|
|
|
// This should throw as testFile should not exist
|
|
await expect(fs.stat(testFile)).rejects.toThrow()
|
|
|
|
await fs.rmdir(testDirectory)
|
|
})
|
|
|
|
test('assertDefined throws if undefined', () => {
|
|
expect(() => cacheUtils.assertDefined('test', undefined)).toThrowError()
|
|
})
|
|
|
|
test('assertDefined returns value', () => {
|
|
expect(cacheUtils.assertDefined('test', 5)).toBe(5)
|
|
})
|