1
0
Fork 0

adding updated lints and fixes

pull/1477/head
Vallie Joseph 2023-07-28 14:12:15 +00:00
parent ba96334e72
commit 20e1b242c8
6 changed files with 48 additions and 50 deletions

View File

@ -239,7 +239,7 @@ describe('Download Tests', () => {
*/ */
async function emptyMockReadBody(): Promise<string> { async function emptyMockReadBody(): Promise<string> {
return new Promise(resolve => { return new Promise(resolve => {
resolve() resolve('mockResolve')
}) })
} }
@ -276,7 +276,7 @@ describe('Download Tests', () => {
] ]
} }
const returnData: string = JSON.stringify(response, null, 2) const returnData: string = JSON.stringify(response, null, 2)
mockReadBody = async function(): Promise<string> { mockReadBody = async function (): Promise<string> {
return new Promise(resolve => { return new Promise(resolve => {
resolve(returnData) resolve(returnData)
}) })
@ -447,7 +447,7 @@ describe('Download Tests', () => {
] ]
} }
const returnData: string = JSON.stringify(response, null, 2) const returnData: string = JSON.stringify(response, null, 2)
mockReadBody = async function(): Promise<string> { mockReadBody = async function (): Promise<string> {
return new Promise(resolve => { return new Promise(resolve => {
resolve(returnData) resolve(returnData)
}) })

View File

@ -65,7 +65,7 @@ beforeAll(async () => {
*/ */
async function emptyMockReadBody(): Promise<string> { async function emptyMockReadBody(): Promise<string> {
return new Promise(resolve => { return new Promise(resolve => {
resolve() resolve('mockResolved')
}) })
} }

View File

@ -2,22 +2,22 @@ import * as http from 'http'
import * as io from '../../io/src/io' import * as io from '../../io/src/io'
import * as net from 'net' import * as net from 'net'
import * as path from 'path' import * as path from 'path'
import {mocked} from 'ts-jest/utils' import { mocked } from 'ts-jest/utils'
import {exec, execSync} from 'child_process' import { exec, execSync } from 'child_process'
import {createGunzip} from 'zlib' import { createGunzip } from 'zlib'
import {promisify} from 'util' import { promisify } from 'util'
import {UploadHttpClient} from '../src/internal/upload-http-client' import { UploadHttpClient } from '../src/internal/upload-http-client'
import * as core from '@actions/core' import * as core from '@actions/core'
import {promises as fs} from 'fs' import { promises as fs } from 'fs'
import {getRuntimeUrl} from '../src/internal/config-variables' import { getRuntimeUrl } from '../src/internal/config-variables'
import {HttpClient, HttpClientResponse} from '@actions/http-client' import { HttpClient, HttpClientResponse } from '@actions/http-client'
import { import {
ArtifactResponse, ArtifactResponse,
PatchArtifactSizeSuccessResponse PatchArtifactSizeSuccessResponse
} from '../src/internal/contracts' } from '../src/internal/contracts'
import {UploadSpecification} from '../src/internal/upload-specification' import { UploadSpecification } from '../src/internal/upload-specification'
import {getArtifactUrl} from '../src/internal/utils' import { getArtifactUrl } from '../src/internal/utils'
import {UploadOptions} from '../src/internal/upload-options' import { UploadOptions } from '../src/internal/upload-options'
const root = path.join(__dirname, '_temp', 'artifact-upload') const root = path.join(__dirname, '_temp', 'artifact-upload')
const file1Path = path.join(root, 'file1.txt') const file1Path = path.join(root, 'file1.txt')
@ -38,11 +38,11 @@ jest.mock('@actions/http-client')
describe('Upload Tests', () => { describe('Upload Tests', () => {
beforeAll(async () => { beforeAll(async () => {
// mock all output so that there is less noise when running tests // mock all output so that there is less noise when running tests
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(() => { })
// setup mocking for calls that got through the HttpClient // setup mocking for calls that got through the HttpClient
setupHttpClientMock() setupHttpClientMock()
@ -196,7 +196,7 @@ describe('Upload Tests', () => {
// create a named pipe 'pipe' with content 'hello pipe' // create a named pipe 'pipe' with content 'hello pipe'
const content = Buffer.from('hello pipe') const content = Buffer.from('hello pipe')
const pipeFilePath = path.join(root, 'pipe') const pipeFilePath = path.join(root, 'pipe')
await promisify(exec)('mkfifo pipe', {cwd: root}) await promisify(exec)('mkfifo pipe', { cwd: root })
// don't want to await here as that would block until read // don't want to await here as that would block until read
fs.writeFile(pipeFilePath, content) fs.writeFile(pipeFilePath, content)
@ -280,7 +280,7 @@ describe('Upload Tests', () => {
const uploadResult = await uploadHttpClient.uploadArtifactToFileContainer( const uploadResult = await uploadHttpClient.uploadArtifactToFileContainer(
uploadUrl, uploadUrl,
uploadSpecification, uploadSpecification,
{continueOnError: true} { continueOnError: true }
) )
expect(uploadResult.failedItems.length).toEqual(1) expect(uploadResult.failedItems.length).toEqual(1)
expect(uploadResult.uploadSize).toEqual(expectedPartialSize) expect(uploadResult.uploadSize).toEqual(expectedPartialSize)
@ -317,7 +317,7 @@ describe('Upload Tests', () => {
const uploadResult = await uploadHttpClient.uploadArtifactToFileContainer( const uploadResult = await uploadHttpClient.uploadArtifactToFileContainer(
uploadUrl, uploadUrl,
uploadSpecification, uploadSpecification,
{continueOnError: false} { continueOnError: false }
) )
expect(uploadResult.failedItems.length).toEqual(2) expect(uploadResult.failedItems.length).toEqual(2)
expect(uploadResult.uploadSize).toEqual(expectedPartialSize) expect(uploadResult.uploadSize).toEqual(expectedPartialSize)
@ -429,7 +429,7 @@ describe('Upload Tests', () => {
*/ */
async function emptyMockReadBody(): Promise<string> { async function emptyMockReadBody(): Promise<string> {
return new Promise(resolve => { return new Promise(resolve => {
resolve() resolve('mockResolve')
}) })
} }
@ -461,12 +461,11 @@ describe('Upload Tests', () => {
fileContainerResourceUrl: `${getRuntimeUrl()}_apis/resources/Containers/13`, fileContainerResourceUrl: `${getRuntimeUrl()}_apis/resources/Containers/13`,
type: 'actions_storage', type: 'actions_storage',
name: inputData.Name, name: inputData.Name,
url: `${getRuntimeUrl()}_apis/pipelines/1/runs/1/artifacts?artifactName=${ url: `${getRuntimeUrl()}_apis/pipelines/1/runs/1/artifacts?artifactName=${inputData.Name
inputData.Name }`
}`
} }
const returnData: string = JSON.stringify(response, null, 2) const returnData: string = JSON.stringify(response, null, 2)
mockReadBody = async function(): Promise<string> { mockReadBody = async function (): Promise<string> {
return new Promise(resolve => { return new Promise(resolve => {
resolve(returnData) resolve(returnData)
}) })
@ -534,7 +533,7 @@ describe('Upload Tests', () => {
uploadUrl: `${getRuntimeUrl()}_apis/resources/Containers/13` uploadUrl: `${getRuntimeUrl()}_apis/resources/Containers/13`
} }
const returnData: string = JSON.stringify(response, null, 2) const returnData: string = JSON.stringify(response, null, 2)
mockReadBody = async function(): Promise<string> { mockReadBody = async function (): Promise<string> {
return new Promise(resolve => { return new Promise(resolve => {
resolve(returnData) resolve(returnData)
}) })

View File

@ -14,16 +14,16 @@ import {
rmFile, rmFile,
sleep sleep
} from './utils' } from './utils'
import {URL} from 'url' import { URL } from 'url'
import {StatusReporter} from './status-reporter' import { StatusReporter } from './status-reporter'
import {performance} from 'perf_hooks' import { performance } from 'perf_hooks'
import {ListArtifactsResponse, QueryArtifactResponse} from './contracts' import { ListArtifactsResponse, QueryArtifactResponse } from './contracts'
import {HttpClientResponse} from '@actions/http-client' import { HttpClientResponse } from '@actions/http-client'
import {HttpManager} from './http-manager' import { HttpManager } from './http-manager'
import {DownloadItem} from './download-specification' import { DownloadItem } from './download-specification'
import {getDownloadFileConcurrency, getRetryLimit} from './config-variables' import { getDownloadFileConcurrency, getRetryLimit } from './config-variables'
import {IncomingHttpHeaders} from 'http' import { IncomingHttpHeaders } from 'http'
import {retryHttpClientRequest} from './requestUtils' import { retryHttpClientRequest } from './requestUtils'
export class DownloadHttpClient { export class DownloadHttpClient {
// http manager is used for concurrent connections when downloading multiple files at once // http manager is used for concurrent connections when downloading multiple files at once
@ -113,8 +113,7 @@ export class DownloadHttpClient {
if (core.isDebug()) { if (core.isDebug()) {
core.debug( core.debug(
`File: ${++downloadedFiles}/${downloadItems.length}. ${ `File: ${++downloadedFiles}/${downloadItems.length}. ${currentFileToDownload.targetPath
currentFileToDownload.targetPath
} took ${(performance.now() - startTime).toFixed( } took ${(performance.now() - startTime).toFixed(
3 3
)} milliseconds to finish downloading` )} milliseconds to finish downloading`
@ -280,8 +279,8 @@ export class DownloadHttpClient {
// if a throttled status code is received, try to get the retryAfter header value, else differ to standard exponential backoff // if a throttled status code is received, try to get the retryAfter header value, else differ to standard exponential backoff
isThrottledStatusCode(response.message.statusCode) isThrottledStatusCode(response.message.statusCode)
? await backOff( ? await backOff(
tryGetRetryAfterValueTimeInMilliseconds(response.message.headers) tryGetRetryAfterValueTimeInMilliseconds(response.message.headers)
) )
: await backOff() : await backOff()
} else { } else {
// Some unexpected response code, fail immediately and stop the download // Some unexpected response code, fail immediately and stop the download
@ -328,7 +327,7 @@ export class DownloadHttpClient {
}) })
.pipe(destinationStream) .pipe(destinationStream)
.on('close', () => { .on('close', () => {
resolve() resolve('closed')
}) })
.on('error', error => { .on('error', error => {
core.info( core.info(
@ -347,7 +346,7 @@ export class DownloadHttpClient {
}) })
.pipe(destinationStream) .pipe(destinationStream)
.on('close', () => { .on('close', () => {
resolve() resolve('closed')
}) })
.on('error', error => { .on('error', error => {
core.info( core.info(

View File

@ -357,7 +357,7 @@ describe('@actions/exec', () => {
expect(exitCode).toBe(0) expect(exitCode).toBe(0)
}) })
it('Handles child process holding streams open', async function() { it('Handles child process holding streams open', async function () {
const semaphorePath = path.join( const semaphorePath = path.join(
getTestTemp(), getTestTemp(),
'child-process-semaphore.txt' 'child-process-semaphore.txt'
@ -403,7 +403,7 @@ describe('@actions/exec', () => {
fs.unlinkSync(semaphorePath) fs.unlinkSync(semaphorePath)
}, 10000) // this was timing out on some slower hosted macOS runs at default 5s }, 10000) // this was timing out on some slower hosted macOS runs at default 5s
it('Handles child process holding streams open and non-zero exit code', async function() { it('Handles child process holding streams open and non-zero exit code', async function () {
const semaphorePath = path.join( const semaphorePath = path.join(
getTestTemp(), getTestTemp(),
'child-process-semaphore.txt' 'child-process-semaphore.txt'
@ -457,7 +457,7 @@ describe('@actions/exec', () => {
fs.unlinkSync(semaphorePath) fs.unlinkSync(semaphorePath)
}, 10000) // this was timing out on some slower hosted macOS runs at default 5s }, 10000) // this was timing out on some slower hosted macOS runs at default 5s
it('Handles child process holding streams open and stderr', async function() { it('Handles child process holding streams open and stderr', async function () {
const semaphorePath = path.join( const semaphorePath = path.join(
getTestTemp(), getTestTemp(),
'child-process-semaphore.txt' 'child-process-semaphore.txt'

View File

@ -19,7 +19,7 @@ describe('@actions/github', () => {
proxyServer = proxy() proxyServer = proxy()
await new Promise(resolve => { await new Promise(resolve => {
const port = Number(proxyUrl.split(':')[2]) const port = Number(proxyUrl.split(':')[2])
proxyServer.listen(port, () => resolve()) proxyServer.listen(port, () => resolve('mockResolve'))
}) })
proxyServer.on('connect', req => { proxyServer.on('connect', req => {
proxyConnects.push(req.url ?? '') proxyConnects.push(req.url ?? '')
@ -33,7 +33,7 @@ describe('@actions/github', () => {
afterAll(async () => { afterAll(async () => {
// Stop proxy server // Stop proxy server
await new Promise(resolve => { await new Promise(resolve => {
proxyServer.once('close', () => resolve()) proxyServer.once('close', () => resolve('closed'))
proxyServer.close() proxyServer.close()
}) })