2022-06-08 13:20:54 +02:00
|
|
|
import * as fs from 'fs'
|
|
|
|
|
import { PrepareJobResponse } from 'hooklib/lib'
|
|
|
|
|
import { prepareJob, runScriptStep } from '../src/hooks'
|
|
|
|
|
import TestSetup from './test-setup'
|
|
|
|
|
|
|
|
|
|
jest.useRealTimers()
|
|
|
|
|
|
|
|
|
|
let testSetup: TestSetup
|
|
|
|
|
|
2022-06-15 03:41:49 +02:00
|
|
|
let definitions
|
2022-06-08 13:20:54 +02:00
|
|
|
|
|
|
|
|
let prepareJobResponse: PrepareJobResponse
|
|
|
|
|
|
2022-06-15 03:41:49 +02:00
|
|
|
describe('run script step', () => {
|
2022-06-08 13:20:54 +02:00
|
|
|
beforeEach(async () => {
|
|
|
|
|
testSetup = new TestSetup()
|
|
|
|
|
testSetup.initialize()
|
|
|
|
|
|
2022-06-15 03:41:49 +02:00
|
|
|
definitions = {
|
|
|
|
|
prepareJob: testSetup.getPrepareJobDefinition(),
|
|
|
|
|
runScriptStep: testSetup.getRunScriptStepDefinition()
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:20:54 +02:00
|
|
|
const prepareJobOutput = testSetup.createOutputFile(
|
|
|
|
|
'prepare-job-output.json'
|
|
|
|
|
)
|
|
|
|
|
await prepareJob(definitions.prepareJob.args, prepareJobOutput)
|
|
|
|
|
|
|
|
|
|
prepareJobResponse = JSON.parse(fs.readFileSync(prepareJobOutput, 'utf-8'))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('Should run script step without exceptions', async () => {
|
|
|
|
|
await expect(
|
|
|
|
|
runScriptStep(definitions.runScriptStep.args, prepareJobResponse.state)
|
|
|
|
|
).resolves.not.toThrow()
|
|
|
|
|
})
|
|
|
|
|
})
|