1
0
Fork 0

Fix linter complaints

pull/1882/head
Bassem Dghaidi 2024-12-02 04:24:17 -08:00 committed by GitHub
parent 87171e29ca
commit 7ad18fd6bd
2 changed files with 21 additions and 21 deletions

View File

@ -1,13 +1,13 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as path from 'path' import * as path from 'path'
import { saveCache } from '../src/cache' import {saveCache} from '../src/cache'
import * as cacheUtils from '../src/internal/cacheUtils' import * as cacheUtils from '../src/internal/cacheUtils'
import { CacheFilename, CompressionMethod } from '../src/internal/constants' import {CacheFilename, CompressionMethod} from '../src/internal/constants'
import * as config from '../src/internal/config' import * as config from '../src/internal/config'
import * as tar from '../src/internal/tar' import * as tar from '../src/internal/tar'
import { CacheServiceClientJSON } from '../src/generated/results/api/v1/cache.twirp' import {CacheServiceClientJSON} from '../src/generated/results/api/v1/cache.twirp'
import * as cacheHttpClient from '../src/internal/cacheHttpClient' import * as cacheHttpClient from '../src/internal/cacheHttpClient'
import { UploadOptions } from '../src/options' import {UploadOptions} from '../src/options'
let logDebugMock: jest.SpyInstance let logDebugMock: jest.SpyInstance
@ -27,11 +27,11 @@ jest.mock('@azure/storage-blob', () => ({
beforeAll(() => { beforeAll(() => {
process.env['ACTIONS_RUNTIME_TOKEN'] = 'token' process.env['ACTIONS_RUNTIME_TOKEN'] = 'token'
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, 'resolvePaths').mockImplementation(async filePaths => { jest.spyOn(cacheUtils, 'resolvePaths').mockImplementation(async filePaths => {
return filePaths.map(x => path.resolve(x)) return filePaths.map(x => path.resolve(x))
}) })
@ -99,7 +99,7 @@ test('create cache entry failure', async () => {
const createCacheEntryMock = jest const createCacheEntryMock = jest
.spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry') .spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry')
.mockReturnValue(Promise.resolve({ ok: false, signedUploadUrl: '' })) .mockReturnValue(Promise.resolve({ok: false, signedUploadUrl: ''}))
const createTarMock = jest.spyOn(tar, 'createTar') const createTarMock = jest.spyOn(tar, 'createTar')
const finalizeCacheEntryMock = jest.spyOn( const finalizeCacheEntryMock = jest.spyOn(
@ -149,7 +149,7 @@ test('save cache fails if a signedUploadURL was not passed', async () => {
const createCacheEntryMock = jest const createCacheEntryMock = jest
.spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry') .spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry')
.mockReturnValue( .mockReturnValue(
Promise.resolve({ ok: true, signedUploadUrl: signedUploadURL }) Promise.resolve({ok: true, signedUploadUrl: signedUploadURL})
) )
const createTarMock = jest.spyOn(tar, 'createTar') const createTarMock = jest.spyOn(tar, 'createTar')
@ -207,7 +207,7 @@ test('finalize save cache failure', async () => {
const createCacheEntryMock = jest const createCacheEntryMock = jest
.spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry') .spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry')
.mockReturnValue( .mockReturnValue(
Promise.resolve({ ok: true, signedUploadUrl: signedUploadURL }) Promise.resolve({ok: true, signedUploadUrl: signedUploadURL})
) )
const createTarMock = jest.spyOn(tar, 'createTar') const createTarMock = jest.spyOn(tar, 'createTar')
@ -227,7 +227,7 @@ test('finalize save cache failure', async () => {
const finalizeCacheEntryMock = jest const finalizeCacheEntryMock = jest
.spyOn(CacheServiceClientJSON.prototype, 'FinalizeCacheEntryUpload') .spyOn(CacheServiceClientJSON.prototype, 'FinalizeCacheEntryUpload')
.mockReturnValue(Promise.resolve({ ok: false, entryId: '' })) .mockReturnValue(Promise.resolve({ok: false, entryId: ''}))
const cacheId = await saveCache([paths], key, options) const cacheId = await saveCache([paths], key, options)
@ -286,7 +286,7 @@ test('save with valid inputs uploads a cache', async () => {
jest jest
.spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry') .spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry')
.mockReturnValue( .mockReturnValue(
Promise.resolve({ ok: true, signedUploadUrl: signedUploadURL }) Promise.resolve({ok: true, signedUploadUrl: signedUploadURL})
) )
const saveCacheMock = jest.spyOn(cacheHttpClient, 'saveCache') const saveCacheMock = jest.spyOn(cacheHttpClient, 'saveCache')
@ -299,7 +299,7 @@ test('save with valid inputs uploads a cache', async () => {
const finalizeCacheEntryMock = jest const finalizeCacheEntryMock = jest
.spyOn(CacheServiceClientJSON.prototype, 'FinalizeCacheEntryUpload') .spyOn(CacheServiceClientJSON.prototype, 'FinalizeCacheEntryUpload')
.mockReturnValue(Promise.resolve({ ok: true, entryId: cacheId.toString() })) .mockReturnValue(Promise.resolve({ok: true, entryId: cacheId.toString()}))
const expectedCacheId = await saveCache([paths], key) const expectedCacheId = await saveCache([paths], key)

View File

@ -1,5 +1,5 @@
import * as uploadUtils from '../src/internal/uploadUtils' import * as uploadUtils from '../src/internal/uploadUtils'
import { TransferProgressEvent } from '@azure/ms-rest-js' import {TransferProgressEvent} from '@azure/ms-rest-js'
test('upload progress tracked correctly', () => { test('upload progress tracked correctly', () => {
const progress = new uploadUtils.UploadProgress(1000) const progress = new uploadUtils.UploadProgress(1000)
@ -11,7 +11,7 @@ test('upload progress tracked correctly', () => {
expect(progress.getTransferredBytes()).toBe(0) expect(progress.getTransferredBytes()).toBe(0)
expect(progress.isDone()).toBe(false) expect(progress.isDone()).toBe(false)
progress.onProgress()({ loadedBytes: 0 } as TransferProgressEvent) progress.onProgress()({loadedBytes: 0} as TransferProgressEvent)
expect(progress.contentLength).toBe(1000) expect(progress.contentLength).toBe(1000)
expect(progress.sentBytes).toBe(0) expect(progress.sentBytes).toBe(0)
@ -20,7 +20,7 @@ test('upload progress tracked correctly', () => {
expect(progress.getTransferredBytes()).toBe(0) expect(progress.getTransferredBytes()).toBe(0)
expect(progress.isDone()).toBe(false) expect(progress.isDone()).toBe(false)
progress.onProgress()({ loadedBytes: 250 } as TransferProgressEvent) progress.onProgress()({loadedBytes: 250} as TransferProgressEvent)
expect(progress.contentLength).toBe(1000) expect(progress.contentLength).toBe(1000)
expect(progress.sentBytes).toBe(250) expect(progress.sentBytes).toBe(250)
@ -29,7 +29,7 @@ test('upload progress tracked correctly', () => {
expect(progress.getTransferredBytes()).toBe(250) expect(progress.getTransferredBytes()).toBe(250)
expect(progress.isDone()).toBe(false) expect(progress.isDone()).toBe(false)
progress.onProgress()({ loadedBytes: 500 } as TransferProgressEvent) progress.onProgress()({loadedBytes: 500} as TransferProgressEvent)
expect(progress.contentLength).toBe(1000) expect(progress.contentLength).toBe(1000)
expect(progress.sentBytes).toBe(500) expect(progress.sentBytes).toBe(500)
@ -38,7 +38,7 @@ test('upload progress tracked correctly', () => {
expect(progress.getTransferredBytes()).toBe(500) expect(progress.getTransferredBytes()).toBe(500)
expect(progress.isDone()).toBe(false) expect(progress.isDone()).toBe(false)
progress.onProgress()({ loadedBytes: 750 } as TransferProgressEvent) progress.onProgress()({loadedBytes: 750} as TransferProgressEvent)
expect(progress.contentLength).toBe(1000) expect(progress.contentLength).toBe(1000)
expect(progress.sentBytes).toBe(750) expect(progress.sentBytes).toBe(750)
@ -47,7 +47,7 @@ test('upload progress tracked correctly', () => {
expect(progress.getTransferredBytes()).toBe(750) expect(progress.getTransferredBytes()).toBe(750)
expect(progress.isDone()).toBe(false) expect(progress.isDone()).toBe(false)
progress.onProgress()({ loadedBytes: 1000 } as TransferProgressEvent) progress.onProgress()({loadedBytes: 1000} as TransferProgressEvent)
expect(progress.contentLength).toBe(1000) expect(progress.contentLength).toBe(1000)
expect(progress.sentBytes).toBe(1000) expect(progress.sentBytes).toBe(1000)