Initial version of setup-ossutil

This commit is contained in:
Rimo
2020-01-15 16:36:04 +08:00
parent df25824a4d
commit e0feee7e7c
12 changed files with 4415 additions and 309 deletions

View File

@@ -0,0 +1,47 @@
import * as path from 'path'
const TOOL_DIR = path.join(__dirname, 'runner', 'tools')
const TEMP_DIR = path.join(__dirname, 'runner', 'temp')
process.env['RUNNER_TOOL_CACHE'] = TOOL_DIR
process.env['RUNNER_TEMP'] = TEMP_DIR
import * as core from '@actions/core'
import * as io from '@actions/io'
import * as fs from 'fs'
import * as installer from '../src/installer'
const FILE_NAME = process.platform === 'win32' ? 'ossutil.exe' : 'ossutil'
describe('installer tests', () => {
beforeAll(async () => {
await io.rmRF(TOOL_DIR)
await io.rmRF(TEMP_DIR)
}, 60000)
afterAll(async () => {
await io.rmRF(TOOL_DIR)
await io.rmRF(TEMP_DIR)
}, 60000)
it('install ossutil 1.6.10', async () => {
const version = '1.6.10'
await installer.getOssutil(version)
const ossutilDir = path.join(TOOL_DIR, 'ossutil', version, process.arch)
expect(fs.existsSync(`${ossutilDir}.complete`)).toBe(true)
const exist = fs.existsSync(path.join(ossutilDir, FILE_NAME))
expect(exist).toBe(true)
}, 60000)
it('throw if wrong version', async () => {
let thrown = false
try {
await installer.getOssutil('1000.0.0')
} catch (error) {
core.error(error)
thrown = true
}
expect(thrown).toBe(true)
})
})