Fix linting issues
This commit is contained in:
+16
-14
@@ -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 cacheHttpClient from '../src/internal/cacheHttpClient'
|
import * as cacheHttpClient from '../src/internal/cacheHttpClient'
|
||||||
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-client'
|
import {CacheServiceClientJSON} from '../src/generated/results/api/v1/cache.twirp-client'
|
||||||
import { DownloadOptions } from '../src/options'
|
import {DownloadOptions} from '../src/options'
|
||||||
|
|
||||||
jest.mock('../src/internal/cacheHttpClient')
|
jest.mock('../src/internal/cacheHttpClient')
|
||||||
jest.mock('../src/internal/cacheUtils')
|
jest.mock('../src/internal/cacheUtils')
|
||||||
@@ -18,11 +18,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')
|
||||||
@@ -148,7 +148,7 @@ test('restore with gzip compressed cache found', async () => {
|
|||||||
const signedDownloadUrl = 'https://blob-storage.local?signed=true'
|
const signedDownloadUrl = 'https://blob-storage.local?signed=true'
|
||||||
const cacheVersion =
|
const cacheVersion =
|
||||||
'd90f107aaeb22920dba0c637a23c37b5bc497b4dfa3b07fe3f79bf88a273c11b'
|
'd90f107aaeb22920dba0c637a23c37b5bc497b4dfa3b07fe3f79bf88a273c11b'
|
||||||
const options = { useAzureSdk: true } as DownloadOptions
|
const options = {useAzureSdk: true} as DownloadOptions
|
||||||
|
|
||||||
const getCacheVersionMock = jest.spyOn(cacheUtils, 'getCacheVersion')
|
const getCacheVersionMock = jest.spyOn(cacheUtils, 'getCacheVersion')
|
||||||
getCacheVersionMock.mockReturnValue(cacheVersion)
|
getCacheVersionMock.mockReturnValue(cacheVersion)
|
||||||
@@ -224,7 +224,7 @@ test('restore with zstd compressed cache found', async () => {
|
|||||||
const signedDownloadUrl = 'https://blob-storage.local?signed=true'
|
const signedDownloadUrl = 'https://blob-storage.local?signed=true'
|
||||||
const cacheVersion =
|
const cacheVersion =
|
||||||
'8e2e96a184cb0cd6b48285b176c06a418f3d7fce14c29d9886fd1bb4f05c513d'
|
'8e2e96a184cb0cd6b48285b176c06a418f3d7fce14c29d9886fd1bb4f05c513d'
|
||||||
const options = { useAzureSdk: true } as DownloadOptions
|
const options = {useAzureSdk: true} as DownloadOptions
|
||||||
|
|
||||||
const getCacheVersionMock = jest.spyOn(cacheUtils, 'getCacheVersion')
|
const getCacheVersionMock = jest.spyOn(cacheUtils, 'getCacheVersion')
|
||||||
getCacheVersionMock.mockReturnValue(cacheVersion)
|
getCacheVersionMock.mockReturnValue(cacheVersion)
|
||||||
@@ -302,7 +302,7 @@ test('restore with cache found for restore key', async () => {
|
|||||||
const signedDownloadUrl = 'https://blob-storage.local?signed=true'
|
const signedDownloadUrl = 'https://blob-storage.local?signed=true'
|
||||||
const cacheVersion =
|
const cacheVersion =
|
||||||
'b8b58e9bd7b1e8f83d9f05c7e06ea865ba44a0330e07a14db74ac74386677bed'
|
'b8b58e9bd7b1e8f83d9f05c7e06ea865ba44a0330e07a14db74ac74386677bed'
|
||||||
const options = { useAzureSdk: true } as DownloadOptions
|
const options = {useAzureSdk: true} as DownloadOptions
|
||||||
|
|
||||||
const getCacheVersionMock = jest.spyOn(cacheUtils, 'getCacheVersion')
|
const getCacheVersionMock = jest.spyOn(cacheUtils, 'getCacheVersion')
|
||||||
getCacheVersionMock.mockReturnValue(cacheVersion)
|
getCacheVersionMock.mockReturnValue(cacheVersion)
|
||||||
@@ -343,7 +343,9 @@ test('restore with cache found for restore key', async () => {
|
|||||||
const cacheKey = await restoreCache(paths, key, restoreKeys, options)
|
const cacheKey = await restoreCache(paths, key, restoreKeys, options)
|
||||||
|
|
||||||
expect(cacheKey).toBe(restoreKeys[0])
|
expect(cacheKey).toBe(restoreKeys[0])
|
||||||
expect(logInfoMock).toHaveBeenCalledWith(`Cache hit for restore-key: ${restoreKeys[0]}`)
|
expect(logInfoMock).toHaveBeenCalledWith(
|
||||||
|
`Cache hit for restore-key: ${restoreKeys[0]}`
|
||||||
|
)
|
||||||
expect(getCacheVersionMock).toHaveBeenCalledWith(
|
expect(getCacheVersionMock).toHaveBeenCalledWith(
|
||||||
paths,
|
paths,
|
||||||
compressionMethod,
|
compressionMethod,
|
||||||
@@ -379,7 +381,7 @@ test('restore with lookup only enabled', async () => {
|
|||||||
const signedDownloadUrl = 'https://blob-storage.local?signed=true'
|
const signedDownloadUrl = 'https://blob-storage.local?signed=true'
|
||||||
const cacheVersion =
|
const cacheVersion =
|
||||||
'd90f107aaeb22920dba0c637a23c37b5bc497b4dfa3b07fe3f79bf88a273c11b'
|
'd90f107aaeb22920dba0c637a23c37b5bc497b4dfa3b07fe3f79bf88a273c11b'
|
||||||
const options = { lookupOnly: true, useAzureSdk: true } as DownloadOptions
|
const options = {lookupOnly: true, useAzureSdk: true} as DownloadOptions
|
||||||
|
|
||||||
const getCacheVersionMock = jest.spyOn(cacheUtils, 'getCacheVersion')
|
const getCacheVersionMock = jest.spyOn(cacheUtils, 'getCacheVersion')
|
||||||
getCacheVersionMock.mockReturnValue(cacheVersion)
|
getCacheVersionMock.mockReturnValue(cacheVersion)
|
||||||
|
|||||||
Vendored
+7
-7
@@ -3,16 +3,16 @@ import * as path from 'path'
|
|||||||
import * as utils from './internal/cacheUtils'
|
import * as utils from './internal/cacheUtils'
|
||||||
import * as cacheHttpClient from './internal/cacheHttpClient'
|
import * as cacheHttpClient from './internal/cacheHttpClient'
|
||||||
import * as cacheTwirpClient from './internal/shared/cacheTwirpClient'
|
import * as cacheTwirpClient from './internal/shared/cacheTwirpClient'
|
||||||
import { getCacheServiceVersion, isGhes } from './internal/config'
|
import {getCacheServiceVersion, isGhes} from './internal/config'
|
||||||
import { DownloadOptions, UploadOptions } from './options'
|
import {DownloadOptions, UploadOptions} from './options'
|
||||||
import { createTar, extractTar, listTar } from './internal/tar'
|
import {createTar, extractTar, listTar} from './internal/tar'
|
||||||
import {
|
import {
|
||||||
CreateCacheEntryRequest,
|
CreateCacheEntryRequest,
|
||||||
FinalizeCacheEntryUploadRequest,
|
FinalizeCacheEntryUploadRequest,
|
||||||
FinalizeCacheEntryUploadResponse,
|
FinalizeCacheEntryUploadResponse,
|
||||||
GetCacheEntryDownloadURLRequest
|
GetCacheEntryDownloadURLRequest
|
||||||
} from './generated/results/api/v1/cache'
|
} from './generated/results/api/v1/cache'
|
||||||
import { CacheFileSizeLimit } from './internal/constants'
|
import {CacheFileSizeLimit} from './internal/constants'
|
||||||
export class ValidationError extends Error {
|
export class ValidationError extends Error {
|
||||||
constructor(message: string) {
|
constructor(message: string) {
|
||||||
super(message)
|
super(message)
|
||||||
@@ -423,9 +423,9 @@ async function saveCacheV1(
|
|||||||
} else if (reserveCacheResponse?.statusCode === 400) {
|
} else if (reserveCacheResponse?.statusCode === 400) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
reserveCacheResponse?.error?.message ??
|
reserveCacheResponse?.error?.message ??
|
||||||
`Cache size of ~${Math.round(
|
`Cache size of ~${Math.round(
|
||||||
archiveFileSize / (1024 * 1024)
|
archiveFileSize / (1024 * 1024)
|
||||||
)} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`
|
)} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
throw new ReserveCacheError(
|
throw new ReserveCacheError(
|
||||||
|
|||||||
Reference in New Issue
Block a user