mirror of https://github.com/actions/toolkit
Fix cache lookup scenario
parent
4dadd612d6
commit
de236da416
|
@ -4,10 +4,10 @@ import * as tar from '../src/internal/tar'
|
||||||
import * as config from '../src/internal/config'
|
import * as config from '../src/internal/config'
|
||||||
import * as cacheUtils from '../src/internal/cacheUtils'
|
import * as cacheUtils from '../src/internal/cacheUtils'
|
||||||
import * as downloadCacheModule from '../src/internal/blob/download-cache'
|
import * as downloadCacheModule from '../src/internal/blob/download-cache'
|
||||||
import { restoreCache } from '../src/cache'
|
import {restoreCache} from '../src/cache'
|
||||||
import { CacheFilename, CompressionMethod } from '../src/internal/constants'
|
import {CacheFilename, CompressionMethod} from '../src/internal/constants'
|
||||||
import { CacheServiceClientJSON } from '../src/generated/results/api/v1/cache.twirp'
|
import {CacheServiceClientJSON} from '../src/generated/results/api/v1/cache.twirp'
|
||||||
import { BlobDownloadResponseParsed } from '@azure/storage-blob'
|
import {BlobDownloadResponseParsed} from '@azure/storage-blob'
|
||||||
// import {executePromisesSequentially} from '@azure/ms-rest-js'
|
// import {executePromisesSequentially} from '@azure/ms-rest-js'
|
||||||
|
|
||||||
jest.mock('../src/internal/cacheHttpClient')
|
jest.mock('../src/internal/cacheHttpClient')
|
||||||
|
@ -19,11 +19,11 @@ let logDebugMock: jest.SpyInstance
|
||||||
let logInfoMock: jest.SpyInstance
|
let logInfoMock: jest.SpyInstance
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
jest.spyOn(console, 'log').mockImplementation(() => { })
|
jest.spyOn(console, 'log').mockImplementation(() => {})
|
||||||
jest.spyOn(core, 'debug').mockImplementation(() => { })
|
jest.spyOn(core, 'debug').mockImplementation(() => {})
|
||||||
jest.spyOn(core, 'info').mockImplementation(() => { })
|
jest.spyOn(core, 'info').mockImplementation(() => {})
|
||||||
jest.spyOn(core, 'warning').mockImplementation(() => { })
|
jest.spyOn(core, 'warning').mockImplementation(() => {})
|
||||||
jest.spyOn(core, 'error').mockImplementation(() => { })
|
jest.spyOn(core, 'error').mockImplementation(() => {})
|
||||||
|
|
||||||
jest.spyOn(cacheUtils, 'getCacheFileName').mockImplementation(cm => {
|
jest.spyOn(cacheUtils, 'getCacheFileName').mockImplementation(cm => {
|
||||||
const actualUtils = jest.requireActual('../src/internal/cacheUtils')
|
const actualUtils = jest.requireActual('../src/internal/cacheUtils')
|
||||||
|
@ -357,7 +357,7 @@ test('restore with cache found for restore key', async () => {
|
||||||
)
|
)
|
||||||
expect(getCacheDownloadURLMock).toHaveBeenCalledWith({
|
expect(getCacheDownloadURLMock).toHaveBeenCalledWith({
|
||||||
key,
|
key,
|
||||||
restoreKeys: restoreKeys,
|
restoreKeys,
|
||||||
version: cacheVersion
|
version: cacheVersion
|
||||||
})
|
})
|
||||||
expect(createTempDirectoryMock).toHaveBeenCalledTimes(1)
|
expect(createTempDirectoryMock).toHaveBeenCalledTimes(1)
|
||||||
|
@ -380,7 +380,7 @@ test('restore with cache found for restore key', async () => {
|
||||||
test('restore with dry run', async () => {
|
test('restore with dry run', async () => {
|
||||||
const paths = ['node_modules']
|
const paths = ['node_modules']
|
||||||
const key = 'node-test'
|
const key = 'node-test'
|
||||||
const options = { lookupOnly: true }
|
const options = {lookupOnly: true}
|
||||||
const compressionMethod = CompressionMethod.Gzip
|
const compressionMethod = CompressionMethod.Gzip
|
||||||
const signedDownloadUrl = 'https://blob-storage.local?signed=true'
|
const signedDownloadUrl = 'https://blob-storage.local?signed=true'
|
||||||
const cacheVersion =
|
const cacheVersion =
|
||||||
|
|
|
@ -261,7 +261,7 @@ async function restoreCacheV2(
|
||||||
|
|
||||||
if (options?.lookupOnly) {
|
if (options?.lookupOnly) {
|
||||||
core.info('Lookup only - skipping download')
|
core.info('Lookup only - skipping download')
|
||||||
return request.key
|
return response.matchedKey
|
||||||
}
|
}
|
||||||
|
|
||||||
archivePath = path.join(
|
archivePath = path.join(
|
||||||
|
|
Loading…
Reference in New Issue