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

View File

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

View File

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

View File

@ -357,7 +357,7 @@ describe('@actions/exec', () => {
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(
getTestTemp(),
'child-process-semaphore.txt'
@ -403,7 +403,7 @@ describe('@actions/exec', () => {
fs.unlinkSync(semaphorePath)
}, 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(
getTestTemp(),
'child-process-semaphore.txt'
@ -457,7 +457,7 @@ describe('@actions/exec', () => {
fs.unlinkSync(semaphorePath)
}, 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(
getTestTemp(),
'child-process-semaphore.txt'

View File

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