mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-03 15:23:15 +08:00
Add option for concurrent cache downloads with timeout (#1484)
* Add option for concurrent cache downloads with timeout * Add release notes * Fix lint
This commit is contained in:
27
packages/cache/__tests__/cacheHttpClient.test.ts
vendored
27
packages/cache/__tests__/cacheHttpClient.test.ts
vendored
@@ -84,18 +84,24 @@ test('downloadCache uses storage SDK for Azure storage URLs', async () => {
|
||||
'downloadCacheStorageSDK'
|
||||
)
|
||||
|
||||
const downloadCacheHttpClientConcurrentMock = jest.spyOn(
|
||||
downloadUtils,
|
||||
'downloadCacheHttpClientConcurrent'
|
||||
)
|
||||
|
||||
const archiveLocation = 'http://foo.blob.core.windows.net/bar/baz'
|
||||
const archivePath = '/foo/bar'
|
||||
|
||||
await downloadCache(archiveLocation, archivePath)
|
||||
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalledTimes(1)
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalledWith(
|
||||
expect(downloadCacheHttpClientConcurrentMock).toHaveBeenCalledTimes(1)
|
||||
expect(downloadCacheHttpClientConcurrentMock).toHaveBeenCalledWith(
|
||||
archiveLocation,
|
||||
archivePath,
|
||||
getDownloadOptions()
|
||||
)
|
||||
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalledTimes(0)
|
||||
expect(downloadCacheHttpClientMock).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
@@ -109,20 +115,26 @@ test('downloadCache passes options to download methods', async () => {
|
||||
'downloadCacheStorageSDK'
|
||||
)
|
||||
|
||||
const downloadCacheHttpClientConcurrentMock = jest.spyOn(
|
||||
downloadUtils,
|
||||
'downloadCacheHttpClientConcurrent'
|
||||
)
|
||||
|
||||
const archiveLocation = 'http://foo.blob.core.windows.net/bar/baz'
|
||||
const archivePath = '/foo/bar'
|
||||
const options: DownloadOptions = {downloadConcurrency: 4}
|
||||
|
||||
await downloadCache(archiveLocation, archivePath, options)
|
||||
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalledTimes(1)
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalled()
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalledWith(
|
||||
expect(downloadCacheHttpClientConcurrentMock).toHaveBeenCalledTimes(1)
|
||||
expect(downloadCacheHttpClientConcurrentMock).toHaveBeenCalled()
|
||||
expect(downloadCacheHttpClientConcurrentMock).toHaveBeenCalledWith(
|
||||
archiveLocation,
|
||||
archivePath,
|
||||
getDownloadOptions(options)
|
||||
)
|
||||
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalledTimes(0)
|
||||
expect(downloadCacheHttpClientMock).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
@@ -138,7 +150,10 @@ test('downloadCache uses http-client when overridden', async () => {
|
||||
|
||||
const archiveLocation = 'http://foo.blob.core.windows.net/bar/baz'
|
||||
const archivePath = '/foo/bar'
|
||||
const options: DownloadOptions = {useAzureSdk: false}
|
||||
const options: DownloadOptions = {
|
||||
useAzureSdk: false,
|
||||
concurrentBlobDownloads: false
|
||||
}
|
||||
|
||||
await downloadCache(archiveLocation, archivePath, options)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user