Add more tests for restoreCacheV2

This commit is contained in:
Bassem Dghaidi
2024-11-25 03:53:03 -08:00
committed by GitHub
parent 27dfd2c41c
commit 4de30f744e
3 changed files with 216 additions and 179 deletions

View File

@@ -3,18 +3,18 @@ import * as path from 'path'
import * as utils from './internal/cacheUtils'
import * as cacheHttpClient from './internal/cacheHttpClient'
import * as cacheTwirpClient from './internal/shared/cacheTwirpClient'
import { getCacheServiceVersion, isGhes } from './internal/config'
import { DownloadOptions, UploadOptions } from './options'
import { createTar, extractTar, listTar } from './internal/tar'
import {getCacheServiceVersion, isGhes} from './internal/config'
import {DownloadOptions, UploadOptions} from './options'
import {createTar, extractTar, listTar} from './internal/tar'
import {
CreateCacheEntryRequest,
FinalizeCacheEntryUploadRequest,
FinalizeCacheEntryUploadResponse,
GetCacheEntryDownloadURLRequest
} from './generated/results/api/v1/cache'
import { CacheFileSizeLimit } from './internal/constants'
import { uploadCacheFile } from './internal/blob/upload-cache'
import { downloadCacheFile } from './internal/blob/download-cache'
import {CacheFileSizeLimit} from './internal/constants'
import {uploadCacheFile} from './internal/blob/upload-cache'
import {downloadCacheFile} from './internal/blob/download-cache'
export class ValidationError extends Error {
constructor(message: string) {
super(message)
@@ -405,9 +405,9 @@ async function saveCacheV1(
} else if (reserveCacheResponse?.statusCode === 400) {
throw new Error(
reserveCacheResponse?.error?.message ??
`Cache size of ~${Math.round(
archiveFileSize / (1024 * 1024)
)} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`
`Cache size of ~${Math.round(
archiveFileSize / (1024 * 1024)
)} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`
)
} else {
throw new ReserveCacheError(

View File

@@ -3,13 +3,14 @@ import * as core from '@actions/core'
import {
BlobClient,
BlockBlobClient,
BlobDownloadOptions
BlobDownloadOptions,
BlobDownloadResponseParsed
} from '@azure/storage-blob'
export async function downloadCacheFile(
signedUploadURL: string,
archivePath: string
): Promise<{}> {
): Promise<BlobDownloadResponseParsed> {
const downloadOptions: BlobDownloadOptions = {
maxRetryRequests: 5
}