Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add restore tests #1876

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
327 changes: 327 additions & 0 deletions packages/cache/__tests__/restoreCacheV2.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,327 @@
import * as core from '@actions/core'
import * as path from 'path'

Check failure on line 2 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 20.x)

'path' is defined but never used

Check failure on line 2 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 20.x)

'path' is defined but never used

Check failure on line 2 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 18.x)

'path' is defined but never used

Check failure on line 2 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20.x)

'path' is defined but never used

Check failure on line 2 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 18.x)

'path' is defined but never used

Check failure on line 2 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 18.x)

'path' is defined but never used
import * as tar from '../src/internal/tar'

Check failure on line 3 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 20.x)

'tar' is defined but never used

Check failure on line 3 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 20.x)

'tar' is defined but never used

Check failure on line 3 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 18.x)

'tar' is defined but never used

Check failure on line 3 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20.x)

'tar' is defined but never used

Check failure on line 3 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 18.x)

'tar' is defined but never used

Check failure on line 3 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 18.x)

'tar' is defined but never used
import * as config from '../src/internal/config'
import * as cacheUtils from '../src/internal/cacheUtils'
import * as cacheHttpClient from '../src/internal/cacheHttpClient'

Check failure on line 6 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 20.x)

'cacheHttpClient' is defined but never used

Check failure on line 6 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 20.x)

'cacheHttpClient' is defined but never used

Check failure on line 6 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 18.x)

'cacheHttpClient' is defined but never used

Check failure on line 6 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20.x)

'cacheHttpClient' is defined but never used

Check failure on line 6 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 18.x)

'cacheHttpClient' is defined but never used

Check failure on line 6 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 18.x)

'cacheHttpClient' is defined but never used
import { restoreCache } from '../src/cache'

Check failure on line 7 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 20.x)

Replace `·restoreCache·` with `restoreCache`

Check failure on line 7 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 20.x)

Replace `·restoreCache·` with `restoreCache`

Check failure on line 7 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 18.x)

Replace `·restoreCache·` with `restoreCache`

Check failure on line 7 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20.x)

Replace `·restoreCache·` with `restoreCache`

Check failure on line 7 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 18.x)

Replace `·restoreCache·` with `restoreCache`

Check failure on line 7 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 18.x)

Replace `·restoreCache·` with `restoreCache`
import { CacheFilename, CompressionMethod } from '../src/internal/constants'

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 20.x)

Replace `·CacheFilename,·CompressionMethod·` with `CacheFilename,·CompressionMethod`

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 20.x)

'CacheFilename' is defined but never used

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 20.x)

'CompressionMethod' is defined but never used

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 20.x)

Replace `·CacheFilename,·CompressionMethod·` with `CacheFilename,·CompressionMethod`

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 20.x)

'CacheFilename' is defined but never used

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 20.x)

'CompressionMethod' is defined but never used

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 18.x)

Replace `·CacheFilename,·CompressionMethod·` with `CacheFilename,·CompressionMethod`

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 18.x)

'CacheFilename' is defined but never used

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 18.x)

'CompressionMethod' is defined but never used

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20.x)

Replace `·CacheFilename,·CompressionMethod·` with `CacheFilename,·CompressionMethod`

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20.x)

'CacheFilename' is defined but never used

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20.x)

'CompressionMethod' is defined but never used

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 18.x)

Replace `·CacheFilename,·CompressionMethod·` with `CacheFilename,·CompressionMethod`

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 18.x)

'CacheFilename' is defined but never used

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 18.x)

'CompressionMethod' is defined but never used

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 18.x)

Replace `·CacheFilename,·CompressionMethod·` with `CacheFilename,·CompressionMethod`

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 18.x)

'CacheFilename' is defined but never used

Check failure on line 8 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 18.x)

'CompressionMethod' is defined but never used
import { ArtifactCacheEntry } from '../src/internal/contracts'

Check failure on line 9 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 20.x)

Replace `·ArtifactCacheEntry·` with `ArtifactCacheEntry`

Check failure on line 9 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 20.x)

'ArtifactCacheEntry' is defined but never used

Check failure on line 9 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 20.x)

Replace `·ArtifactCacheEntry·` with `ArtifactCacheEntry`

Check failure on line 9 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 20.x)

'ArtifactCacheEntry' is defined but never used

Check failure on line 9 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 18.x)

Replace `·ArtifactCacheEntry·` with `ArtifactCacheEntry`

Check failure on line 9 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 18.x)

'ArtifactCacheEntry' is defined but never used

Check failure on line 9 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20.x)

Replace `·ArtifactCacheEntry·` with `ArtifactCacheEntry`

Check failure on line 9 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20.x)

'ArtifactCacheEntry' is defined but never used

Check failure on line 9 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 18.x)

Replace `·ArtifactCacheEntry·` with `ArtifactCacheEntry`

Check failure on line 9 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 18.x)

'ArtifactCacheEntry' is defined but never used

Check failure on line 9 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 18.x)

Replace `·ArtifactCacheEntry·` with `ArtifactCacheEntry`

Check failure on line 9 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 18.x)

'ArtifactCacheEntry' is defined but never used
import { CacheServiceClientJSON } from '../src/generated/results/api/v1/cache.twirp'

Check failure on line 10 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 20.x)

Replace `·CacheServiceClientJSON·` with `CacheServiceClientJSON`

Check failure on line 10 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 20.x)

Replace `·CacheServiceClientJSON·` with `CacheServiceClientJSON`

Check failure on line 10 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest-large, 18.x)

Replace `·CacheServiceClientJSON·` with `CacheServiceClientJSON`

Check failure on line 10 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20.x)

Replace `·CacheServiceClientJSON·` with `CacheServiceClientJSON`

Check failure on line 10 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 18.x)

Replace `·CacheServiceClientJSON·` with `CacheServiceClientJSON`

Check failure on line 10 in packages/cache/__tests__/restoreCacheV2.test.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 18.x)

Replace `·CacheServiceClientJSON·` with `CacheServiceClientJSON`

jest.mock('../src/internal/cacheHttpClient')
jest.mock('../src/internal/cacheUtils')
jest.mock('../src/internal/config')
jest.mock('../src/internal/tar')

beforeAll(() => {
jest.spyOn(console, 'log').mockImplementation(() => { })
jest.spyOn(core, 'debug').mockImplementation(() => { })
jest.spyOn(core, 'info').mockImplementation(() => { })
jest.spyOn(core, 'warning').mockImplementation(() => { })
jest.spyOn(core, 'error').mockImplementation(() => { })

jest.spyOn(cacheUtils, 'getCacheFileName').mockImplementation(cm => {
const actualUtils = jest.requireActual('../src/internal/cacheUtils')
return actualUtils.getCacheFileName(cm)
})

// Ensure that we're using v2 for these tests
jest.spyOn(config, 'getCacheServiceVersion').mockReturnValue('v2')
})

test('restore with no path should fail', async () => {
const paths: string[] = []
const key = 'node-test'
await expect(restoreCache(paths, key)).rejects.toThrowError(
`Path Validation Error: At least one directory or file path is required`
)
})

test('restore with too many keys should fail', async () => {
const paths = ['node_modules']
const key = 'node-test'
const restoreKeys = [...Array(20).keys()].map(x => x.toString())
await expect(restoreCache(paths, key, restoreKeys)).rejects.toThrowError(
`Key Validation Error: Keys are limited to a maximum of 10.`
)
})

test('restore with large key should fail', async () => {
const paths = ['node_modules']
const key = 'foo'.repeat(512) // Over the 512 character limit
await expect(restoreCache(paths, key)).rejects.toThrowError(
`Key Validation Error: ${key} cannot be larger than 512 characters.`
)
})

test('restore with invalid key should fail', async () => {
const paths = ['node_modules']
const key = 'comma,comma'
await expect(restoreCache(paths, key)).rejects.toThrowError(
`Key Validation Error: ${key} cannot contain commas.`
)
})

test('restore with no cache found', async () => {
const paths = ['node_modules']
const key = 'node-test'

jest
.spyOn(CacheServiceClientJSON.prototype, 'GetCacheEntryDownloadURL')
.mockReturnValue(Promise.resolve({ ok: false, signedDownloadUrl: '' }))

const cacheKey = await restoreCache(paths, key)

expect(cacheKey).toBe(undefined)
})

test('restore with server error should fail', async () => {
const paths = ['node_modules']
const key = 'node-test'
const logWarningMock = jest.spyOn(core, 'warning')

jest
.spyOn(CacheServiceClientJSON.prototype, 'GetCacheEntryDownloadURL')
.mockImplementation(() => {
throw new Error('HTTP Error Occurred')
})

const cacheKey = await restoreCache(paths, key)
expect(cacheKey).toBe(undefined)
expect(logWarningMock).toHaveBeenCalledTimes(1)
expect(logWarningMock).toHaveBeenCalledWith(
'Failed to restore: HTTP Error Occurred'
)
})

// test('restore with restore keys and no cache found', async () => {
// const paths = ['node_modules']
// const key = 'node-test'
// const restoreKey = 'node-'

// jest
// .spyOn(CacheServiceClientJSON.prototype, 'GetCacheEntryDownloadURL')
// .mockImplementation(() => {
// return Promise.resolve(null)
// })
// jest.spyOn(cacheHttpClient, 'getCacheEntry').mockImplementation(async () => {
// return Promise.resolve(null)
// })

// const cacheKey = await restoreCache(paths, key, [restoreKey])

// expect(cacheKey).toBe(undefined)
// })

// test('restore with gzip compressed cache found', async () => {
// const paths = ['node_modules']
// const key = 'node-test'

// const cacheEntry: ArtifactCacheEntry = {
// cacheKey: key,
// scope: 'refs/heads/main',
// archiveLocation: 'www.actionscache.test/download'
// }
// const getCacheMock = jest.spyOn(cacheHttpClient, 'getCacheEntry')
// getCacheMock.mockImplementation(async () => {
// return Promise.resolve(cacheEntry)
// })

// const tempPath = '/foo/bar'

// const createTempDirectoryMock = jest.spyOn(cacheUtils, 'createTempDirectory')
// createTempDirectoryMock.mockImplementation(async () => {
// return Promise.resolve(tempPath)
// })

// const archivePath = path.join(tempPath, CacheFilename.Gzip)
// const downloadCacheMock = jest.spyOn(cacheHttpClient, 'downloadCache')

// const fileSize = 142
// const getArchiveFileSizeInBytesMock = jest
// .spyOn(cacheUtils, 'getArchiveFileSizeInBytes')
// .mockReturnValue(fileSize)

// const extractTarMock = jest.spyOn(tar, 'extractTar')
// const unlinkFileMock = jest.spyOn(cacheUtils, 'unlinkFile')

// const compression = CompressionMethod.Gzip
// const getCompressionMock = jest
// .spyOn(cacheUtils, 'getCompressionMethod')
// .mockReturnValue(Promise.resolve(compression))

// const cacheKey = await restoreCache(paths, key)

// expect(cacheKey).toBe(key)
// expect(getCacheMock).toHaveBeenCalledWith([key], paths, {
// compressionMethod: compression,
// enableCrossOsArchive: false
// })
// expect(createTempDirectoryMock).toHaveBeenCalledTimes(1)
// expect(downloadCacheMock).toHaveBeenCalledWith(
// cacheEntry.archiveLocation,
// archivePath,
// undefined
// )
// expect(getArchiveFileSizeInBytesMock).toHaveBeenCalledWith(archivePath)

// expect(extractTarMock).toHaveBeenCalledTimes(1)
// expect(extractTarMock).toHaveBeenCalledWith(archivePath, compression)

// expect(unlinkFileMock).toHaveBeenCalledTimes(1)
// expect(unlinkFileMock).toHaveBeenCalledWith(archivePath)

// expect(getCompressionMock).toHaveBeenCalledTimes(1)
// })

// test('restore with zstd compressed cache found', async () => {
// const paths = ['node_modules']
// const key = 'node-test'

// const infoMock = jest.spyOn(core, 'info')

// const cacheEntry: ArtifactCacheEntry = {
// cacheKey: key,
// scope: 'refs/heads/main',
// archiveLocation: 'www.actionscache.test/download'
// }
// const getCacheMock = jest.spyOn(cacheHttpClient, 'getCacheEntry')
// getCacheMock.mockImplementation(async () => {
// return Promise.resolve(cacheEntry)
// })
// const tempPath = '/foo/bar'

// const createTempDirectoryMock = jest.spyOn(cacheUtils, 'createTempDirectory')
// createTempDirectoryMock.mockImplementation(async () => {
// return Promise.resolve(tempPath)
// })

// const archivePath = path.join(tempPath, CacheFilename.Zstd)
// const downloadCacheMock = jest.spyOn(cacheHttpClient, 'downloadCache')

// const fileSize = 62915000
// const getArchiveFileSizeInBytesMock = jest
// .spyOn(cacheUtils, 'getArchiveFileSizeInBytes')
// .mockReturnValue(fileSize)

// const extractTarMock = jest.spyOn(tar, 'extractTar')
// const compression = CompressionMethod.Zstd
// const getCompressionMock = jest
// .spyOn(cacheUtils, 'getCompressionMethod')
// .mockReturnValue(Promise.resolve(compression))

// const cacheKey = await restoreCache(paths, key)

// expect(cacheKey).toBe(key)
// expect(getCacheMock).toHaveBeenCalledWith([key], paths, {
// compressionMethod: compression,
// enableCrossOsArchive: false
// })
// expect(createTempDirectoryMock).toHaveBeenCalledTimes(1)
// expect(downloadCacheMock).toHaveBeenCalledWith(
// cacheEntry.archiveLocation,
// archivePath,
// undefined
// )
// expect(getArchiveFileSizeInBytesMock).toHaveBeenCalledWith(archivePath)
// expect(infoMock).toHaveBeenCalledWith(`Cache Size: ~60 MB (62915000 B)`)

// expect(extractTarMock).toHaveBeenCalledTimes(1)
// expect(extractTarMock).toHaveBeenCalledWith(archivePath, compression)
// expect(getCompressionMock).toHaveBeenCalledTimes(1)
// })

// test('restore with cache found for restore key', async () => {
// const paths = ['node_modules']
// const key = 'node-test'
// const restoreKey = 'node-'

// const infoMock = jest.spyOn(core, 'info')

// const cacheEntry: ArtifactCacheEntry = {
// cacheKey: restoreKey,
// scope: 'refs/heads/main',
// archiveLocation: 'www.actionscache.test/download'
// }
// const getCacheMock = jest.spyOn(cacheHttpClient, 'getCacheEntry')
// getCacheMock.mockImplementation(async () => {
// return Promise.resolve(cacheEntry)
// })
// const tempPath = '/foo/bar'

// const createTempDirectoryMock = jest.spyOn(cacheUtils, 'createTempDirectory')
// createTempDirectoryMock.mockImplementation(async () => {
// return Promise.resolve(tempPath)
// })

// const archivePath = path.join(tempPath, CacheFilename.Zstd)
// const downloadCacheMock = jest.spyOn(cacheHttpClient, 'downloadCache')

// const fileSize = 142
// const getArchiveFileSizeInBytesMock = jest
// .spyOn(cacheUtils, 'getArchiveFileSizeInBytes')
// .mockReturnValue(fileSize)

// const extractTarMock = jest.spyOn(tar, 'extractTar')
// const compression = CompressionMethod.Zstd
// const getCompressionMock = jest
// .spyOn(cacheUtils, 'getCompressionMethod')
// .mockReturnValue(Promise.resolve(compression))

// const cacheKey = await restoreCache(paths, key, [restoreKey])

// expect(cacheKey).toBe(restoreKey)
// expect(getCacheMock).toHaveBeenCalledWith([key, restoreKey], paths, {
// compressionMethod: compression,
// enableCrossOsArchive: false
// })
// expect(createTempDirectoryMock).toHaveBeenCalledTimes(1)
// expect(downloadCacheMock).toHaveBeenCalledWith(
// cacheEntry.archiveLocation,
// archivePath,
// undefined
// )
// expect(getArchiveFileSizeInBytesMock).toHaveBeenCalledWith(archivePath)
// expect(infoMock).toHaveBeenCalledWith(`Cache Size: ~0 MB (142 B)`)

// expect(extractTarMock).toHaveBeenCalledTimes(1)
// expect(extractTarMock).toHaveBeenCalledWith(archivePath, compression)
// expect(getCompressionMock).toHaveBeenCalledTimes(1)
// })

// test('restore with dry run', async () => {
// const paths = ['node_modules']
// const key = 'node-test'
// const options = { lookupOnly: true }

// const cacheEntry: ArtifactCacheEntry = {
// cacheKey: key,
// scope: 'refs/heads/main',
// archiveLocation: 'www.actionscache.test/download'
// }
// const getCacheMock = jest.spyOn(cacheHttpClient, 'getCacheEntry')
// getCacheMock.mockImplementation(async () => {
// return Promise.resolve(cacheEntry)
// })

// const createTempDirectoryMock = jest.spyOn(cacheUtils, 'createTempDirectory')
// const downloadCacheMock = jest.spyOn(cacheHttpClient, 'downloadCache')

// const compression = CompressionMethod.Gzip
// const getCompressionMock = jest
// .spyOn(cacheUtils, 'getCompressionMethod')
// .mockReturnValue(Promise.resolve(compression))

// const cacheKey = await restoreCache(paths, key, undefined, options)

// expect(cacheKey).toBe(key)
// expect(getCompressionMock).toHaveBeenCalledTimes(1)
// expect(getCacheMock).toHaveBeenCalledWith([key], paths, {
// compressionMethod: compression,
// enableCrossOsArchive: false
// })
// // creating a tempDir and downloading the cache are skipped
// expect(createTempDirectoryMock).toHaveBeenCalledTimes(0)
// expect(downloadCacheMock).toHaveBeenCalledTimes(0)
// })
Loading
Loading