Initial version of setup-ossutil
This commit is contained in:
47
__tests__/installer.test.ts
Normal file
47
__tests__/installer.test.ts
Normal 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)
|
||||
})
|
||||
})
|
||||
@@ -1,27 +0,0 @@
|
||||
import {wait} from '../src/wait'
|
||||
import * as process from 'process'
|
||||
import * as cp from 'child_process'
|
||||
import * as path from 'path'
|
||||
|
||||
test('throws invalid number', async () => {
|
||||
const input = parseInt('foo', 10)
|
||||
await expect(wait(input)).rejects.toThrow('milliseconds not a number')
|
||||
})
|
||||
|
||||
test('wait 500 ms', async () => {
|
||||
const start = new Date()
|
||||
await wait(500)
|
||||
const end = new Date()
|
||||
var delta = Math.abs(end.getTime() - start.getTime())
|
||||
expect(delta).toBeGreaterThan(450)
|
||||
})
|
||||
|
||||
// shows how the runner will run a javascript action with env / stdout protocol
|
||||
test('test runs', () => {
|
||||
process.env['INPUT_MILLISECONDS'] = '500'
|
||||
const ip = path.join(__dirname, '..', 'lib', 'main.js')
|
||||
const options: cp.ExecSyncOptions = {
|
||||
env: process.env
|
||||
}
|
||||
console.log(cp.execSync(`node ${ip}`, options).toString())
|
||||
})
|
||||
Reference in New Issue
Block a user