Added cacheSize in ReserveCache API request (#1044)

* Added cacheSize in ReserveCache API request

* minor

* minor

* minor

* Cleanup

* package-lock revert

* Modified tests

* New Response Type

* cleanup

* Linting

* Lint fix

* Resolved comments

* Added tests

* package-lock

* Resolved package-lock mismatch

* Liniting

* Update packages/cache/src/cache.ts

Co-authored-by: Bishal Prasad <bishal-pdmsft@github.com>

* Linting issue

* Resolved few comments

* version upgrade

* Savecache tests

* RequestUtil test

* test

* test

* test

* test

* test

* test

* test

* test

* test

* test

Co-authored-by: Apple <apple@Apples-MacBook-Pro.local>
Co-authored-by: Bishal Prasad <bishal-pdmsft@github.com>
This commit is contained in:
Deepak Dahiya
2022-04-04 16:21:58 +05:30
committed by GitHub
parent 03eca1b0c7
commit f8a69bc473
9 changed files with 209 additions and 41 deletions

View File

@@ -1,5 +1,6 @@
import {retry} from '../src/internal/requestUtils'
import {retry, retryTypedResponse} from '../src/internal/requestUtils'
import {HttpClientError} from '@actions/http-client'
import * as requestUtils from '../src/internal/requestUtils'
interface ITestResponse {
statusCode: number
@@ -145,3 +146,34 @@ test('retry converts errors to response object', async () => {
null
)
})
test('retryTypedResponse gives an error with error message', async () => {
const httpClientError = new HttpClientError(
'The cache filesize must be between 0 and 10 * 1024 * 1024 bytes',
400
)
jest.spyOn(requestUtils, 'retry').mockReturnValue(
new Promise(resolve => {
resolve(httpClientError)
})
)
try {
await retryTypedResponse<string>(
'reserveCache',
async () =>
new Promise(resolve => {
resolve({
statusCode: 400,
result: '',
headers: {},
error: httpClientError
})
})
)
} catch (error) {
expect(error).toHaveProperty(
'message',
'The cache filesize must be between 0 and 10 * 1024 * 1024 bytes'
)
}
})