mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-03-20 10:02:38 +08:00
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:
34
packages/cache/__tests__/requestUtils.test.ts
vendored
34
packages/cache/__tests__/requestUtils.test.ts
vendored
@@ -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'
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user