From d972090333aaa079cb291d48f8556e8dc051d996 Mon Sep 17 00:00:00 2001 From: Minh Nguyen <2852660+NMinhNguyen@users.noreply.github.com> Date: Mon, 3 May 2021 18:09:44 +0300 Subject: [PATCH] Fix typo in function name (#590) --- packages/cache/__tests__/cacheUtils.test.ts | 4 ++-- packages/cache/__tests__/restoreCache.test.ts | 18 +++++++++--------- packages/cache/__tests__/saveCache.test.ts | 2 +- packages/cache/src/cache.ts | 4 ++-- packages/cache/src/internal/cacheHttpClient.ts | 4 ++-- packages/cache/src/internal/cacheUtils.ts | 2 +- packages/cache/src/internal/downloadUtils.ts | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/cache/__tests__/cacheUtils.test.ts b/packages/cache/__tests__/cacheUtils.test.ts index 32a95860..f1f95577 100644 --- a/packages/cache/__tests__/cacheUtils.test.ts +++ b/packages/cache/__tests__/cacheUtils.test.ts @@ -2,10 +2,10 @@ import {promises as fs} from 'fs' import * as path from 'path' import * as cacheUtils from '../src/internal/cacheUtils' -test('getArchiveFileSizeIsBytes returns file size', () => { +test('getArchiveFileSizeInBytes returns file size', () => { const filePath = path.join(__dirname, '__fixtures__', 'helloWorld.txt') - const size = cacheUtils.getArchiveFileSizeIsBytes(filePath) + const size = cacheUtils.getArchiveFileSizeInBytes(filePath) expect(size).toBe(11) }) diff --git a/packages/cache/__tests__/restoreCache.test.ts b/packages/cache/__tests__/restoreCache.test.ts index 5095947c..72d6eadc 100644 --- a/packages/cache/__tests__/restoreCache.test.ts +++ b/packages/cache/__tests__/restoreCache.test.ts @@ -123,8 +123,8 @@ test('restore with gzip compressed cache found', async () => { const downloadCacheMock = jest.spyOn(cacheHttpClient, 'downloadCache') const fileSize = 142 - const getArchiveFileSizeIsBytesMock = jest - .spyOn(cacheUtils, 'getArchiveFileSizeIsBytes') + const getArchiveFileSizeInBytesMock = jest + .spyOn(cacheUtils, 'getArchiveFileSizeInBytes') .mockReturnValue(fileSize) const extractTarMock = jest.spyOn(tar, 'extractTar') @@ -147,7 +147,7 @@ test('restore with gzip compressed cache found', async () => { archivePath, undefined ) - expect(getArchiveFileSizeIsBytesMock).toHaveBeenCalledWith(archivePath) + expect(getArchiveFileSizeInBytesMock).toHaveBeenCalledWith(archivePath) expect(extractTarMock).toHaveBeenCalledTimes(1) expect(extractTarMock).toHaveBeenCalledWith(archivePath, compression) @@ -184,8 +184,8 @@ test('restore with zstd compressed cache found', async () => { const downloadCacheMock = jest.spyOn(cacheHttpClient, 'downloadCache') const fileSize = 62915000 - const getArchiveFileSizeIsBytesMock = jest - .spyOn(cacheUtils, 'getArchiveFileSizeIsBytes') + const getArchiveFileSizeInBytesMock = jest + .spyOn(cacheUtils, 'getArchiveFileSizeInBytes') .mockReturnValue(fileSize) const extractTarMock = jest.spyOn(tar, 'extractTar') @@ -206,7 +206,7 @@ test('restore with zstd compressed cache found', async () => { archivePath, undefined ) - expect(getArchiveFileSizeIsBytesMock).toHaveBeenCalledWith(archivePath) + expect(getArchiveFileSizeInBytesMock).toHaveBeenCalledWith(archivePath) expect(infoMock).toHaveBeenCalledWith(`Cache Size: ~60 MB (62915000 B)`) expect(extractTarMock).toHaveBeenCalledTimes(1) @@ -241,8 +241,8 @@ test('restore with cache found for restore key', async () => { const downloadCacheMock = jest.spyOn(cacheHttpClient, 'downloadCache') const fileSize = 142 - const getArchiveFileSizeIsBytesMock = jest - .spyOn(cacheUtils, 'getArchiveFileSizeIsBytes') + const getArchiveFileSizeInBytesMock = jest + .spyOn(cacheUtils, 'getArchiveFileSizeInBytes') .mockReturnValue(fileSize) const extractTarMock = jest.spyOn(tar, 'extractTar') @@ -263,7 +263,7 @@ test('restore with cache found for restore key', async () => { archivePath, undefined ) - expect(getArchiveFileSizeIsBytesMock).toHaveBeenCalledWith(archivePath) + expect(getArchiveFileSizeInBytesMock).toHaveBeenCalledWith(archivePath) expect(infoMock).toHaveBeenCalledWith(`Cache Size: ~0 MB (142 B)`) expect(extractTarMock).toHaveBeenCalledTimes(1) diff --git a/packages/cache/__tests__/saveCache.test.ts b/packages/cache/__tests__/saveCache.test.ts index 71132878..99ff97e5 100644 --- a/packages/cache/__tests__/saveCache.test.ts +++ b/packages/cache/__tests__/saveCache.test.ts @@ -49,7 +49,7 @@ test('save with large cache outputs should fail', async () => { const cacheSize = 6 * 1024 * 1024 * 1024 //~6GB, over the 5GB limit jest - .spyOn(cacheUtils, 'getArchiveFileSizeIsBytes') + .spyOn(cacheUtils, 'getArchiveFileSizeInBytes') .mockReturnValueOnce(cacheSize) const compression = CompressionMethod.Gzip const getCompressionMock = jest diff --git a/packages/cache/src/cache.ts b/packages/cache/src/cache.ts index a6870f8f..5e333dcc 100644 --- a/packages/cache/src/cache.ts +++ b/packages/cache/src/cache.ts @@ -104,7 +104,7 @@ export async function restoreCache( await listTar(archivePath, compressionMethod) } - const archiveFileSize = utils.getArchiveFileSizeIsBytes(archivePath) + const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath) core.info( `Cache Size: ~${Math.round( archiveFileSize / (1024 * 1024) @@ -172,7 +172,7 @@ export async function saveCache( } const fileSizeLimit = 5 * 1024 * 1024 * 1024 // 5GB per repo limit - const archiveFileSize = utils.getArchiveFileSizeIsBytes(archivePath) + const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath) core.debug(`File Size: ${archiveFileSize}`) if (archiveFileSize > fileSizeLimit) { throw new Error( diff --git a/packages/cache/src/internal/cacheHttpClient.ts b/packages/cache/src/internal/cacheHttpClient.ts index 000257a5..6a46f736 100644 --- a/packages/cache/src/internal/cacheHttpClient.ts +++ b/packages/cache/src/internal/cacheHttpClient.ts @@ -219,7 +219,7 @@ async function uploadFile( options?: UploadOptions ): Promise { // Upload Chunks - const fileSize = fs.statSync(archivePath).size + const fileSize = utils.getArchiveFileSizeInBytes(archivePath) const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`) const fd = fs.openSync(archivePath, 'r') const uploadOptions = getUploadOptions(options) @@ -300,7 +300,7 @@ export async function saveCache( // Commit Cache core.debug('Commiting cache') - const cacheSize = utils.getArchiveFileSizeIsBytes(archivePath) + const cacheSize = utils.getArchiveFileSizeInBytes(archivePath) core.info( `Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)` ) diff --git a/packages/cache/src/internal/cacheUtils.ts b/packages/cache/src/internal/cacheUtils.ts index 36044d48..41096102 100644 --- a/packages/cache/src/internal/cacheUtils.ts +++ b/packages/cache/src/internal/cacheUtils.ts @@ -35,7 +35,7 @@ export async function createTempDirectory(): Promise { return dest } -export function getArchiveFileSizeIsBytes(filePath: string): number { +export function getArchiveFileSizeInBytes(filePath: string): number { return fs.statSync(filePath).size } diff --git a/packages/cache/src/internal/downloadUtils.ts b/packages/cache/src/internal/downloadUtils.ts index a2a52589..0aebd78c 100644 --- a/packages/cache/src/internal/downloadUtils.ts +++ b/packages/cache/src/internal/downloadUtils.ts @@ -190,7 +190,7 @@ export async function downloadCacheHttpClient( if (contentLengthHeader) { const expectedLength = parseInt(contentLengthHeader) - const actualLength = utils.getArchiveFileSizeIsBytes(archivePath) + const actualLength = utils.getArchiveFileSizeInBytes(archivePath) if (actualLength !== expectedLength) { throw new Error(