Skip to content

Commit

Permalink
fix: linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alkoleft committed Nov 18, 2024
1 parent 96d1c0c commit 071979e
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 161 deletions.
93 changes: 43 additions & 50 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,32 @@ import * as installer from '../src/installer'
import * as dotenv from 'dotenv'

// Mock the GitHub Actions core library
const debugMock = jest.spyOn(core, 'debug')
const getInputMock = jest.spyOn(core, 'getInput')
const getBooleanInput = jest.spyOn(core, 'getBooleanInput')
const setFailedMock = jest.spyOn(core, 'setFailed')
const setOutputMock = jest.spyOn(core, 'setOutput')

// Mock the action's entrypoint
const runMock = jest.spyOn(installer, 'run')

// Other utilities
const timeRegex = /^\d{2}:\d{2}:\d{2}/
const TIMEOUT = 50000

// interface Input {
// type?: 'edt'|'onec',
// edt_version?: string,
// onec_version?: string,
// cache?: boolean,
// cache_distr?: boolean
// }

type Input = { [key: string]: string }

function configureInput(input: Input): void {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
return input[name]
})
getBooleanInput.mockImplementation((name: string): boolean => {
return input[name] === 'true'
})
}

describe('action', () => {
// We need to copy/restore the whole property definition, not just the raw value
const realPlatform = Object.getOwnPropertyDescriptor(process, 'platform')
dotenv.config()
beforeEach(() => {
jest.clearAllMocks()
})
afterEach(() => {
if (!realPlatform) {
return
}
// Restore the real property value after each test
Object.defineProperty(process, 'platform', realPlatform)
})

it(
'Download EDT',
Expand All @@ -57,39 +46,43 @@ describe('action', () => {
edt_version: '2023.1.2',
offline: 'true'
}
new Map()
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
return input[name]
})
getBooleanInput.mockImplementation((name: string): boolean => {
return input[name] === 'true'
})

configureInput(input)

await installer.run()
expect(runMock).toHaveReturned()
},
TIMEOUT
),
it(
'Install 1C:Enterprise',
async () => {
const input: Input = {
type: 'onec',
onec_version: '8.3.14.2095',
offline: 'true'
}
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
return input[name]
})
getBooleanInput.mockImplementation((name: string): boolean => {
return input[name] === 'true'
})
)

it(
'Install 1C:Enterprise v. 8.3.14.2095',
async () => {
const input: Input = {
type: 'onec',
onec_version: '8.3.14.2095'
}

configureInput(input)

await installer.run()
expect(runMock).toHaveReturned()
},
TIMEOUT * 10
)
await installer.run()
expect(runMock).toHaveReturned()
},
TIMEOUT * 10
)
it(
'Install 1C:Enterprise v. 8.3.10.2580',
async () => {
const input: Input = {
type: 'onec',
onec_version: '8.3.10.2580'
}

configureInput(input)

await installer.run()
expect(runMock).toHaveReturned()
},
TIMEOUT * 10
)
})
1 change: 0 additions & 1 deletion __tests__/ongetjs.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import OneGet from '../src/onegetjs'
import { downloadRelease } from '../src/onegetjs'
import { config } from 'dotenv'

Expand Down
20 changes: 4 additions & 16 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ export async function run(): Promise<void> {
installerRestored = installerRestoredKey !== undefined
}

if (!installationRestored) {
if (!installerRestored) {
await installer.download()
if (useCacheDistr) {
await installer.saveInstallerCache()
}
}

await installer.install()
await installer.updatePath()

Expand Down
16 changes: 2 additions & 14 deletions src/onegetjs/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,12 @@ function isRedirect(response: Response): boolean {
return response.status === 301 || response.status === 302
}

function cookieString(cookieJar: CookieJar, url: URL): string {
return cookieJar
?.getCookies({
domain: url.host,
path: url.pathname,
secure: true,
script: false
})
.map(c => c.toString())
.join('; ')
}

function parseCookies(response: Response, cookieJar?: CookieJar): void {
if (cookieJar === undefined) {
return
}
response.headers.raw()['set-cookie']?.map(v => {
let c = new Cookie(v)
cookieJar?.setCookie(c)
const cookie = new Cookie(v)
cookieJar?.setCookie(cookie)
})
}
76 changes: 0 additions & 76 deletions src/tools/oneGet.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/tools/platform83.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export class Platform83 extends OnecTool {
installerType = 'clientOrServer'
platformType = 'deb'
}
//releases.1c.ru/version_file?nick=Platform83&ver=8.3.14.2095&path=Platform%5c8_3_14_2095%5cdeb64_8_3_14_2095.tar.gz
https: await downloadRelease(

await downloadRelease(
{
project: 'Platform83',
version: this.version,
Expand Down

0 comments on commit 071979e

Please sign in to comment.