2022-06-02 15:53:11 -04:00
|
|
|
import { runContainerStep } from '../src/hooks'
|
2022-06-06 12:56:50 +02:00
|
|
|
import { TestHelper } from './test-setup'
|
2022-06-02 15:53:11 -04:00
|
|
|
|
|
|
|
|
jest.useRealTimers()
|
|
|
|
|
|
2022-06-06 00:21:44 -04:00
|
|
|
let testHelper: TestHelper
|
2022-06-02 15:53:11 -04:00
|
|
|
|
|
|
|
|
let runContainerStepData: any
|
|
|
|
|
|
|
|
|
|
describe('Run container step', () => {
|
2022-06-15 03:41:49 +02:00
|
|
|
beforeEach(async () => {
|
2022-06-06 00:21:44 -04:00
|
|
|
testHelper = new TestHelper()
|
|
|
|
|
await testHelper.initialize()
|
2022-06-15 03:41:49 +02:00
|
|
|
runContainerStepData = testHelper.getRunContainerStepDefinition()
|
2022-06-02 15:53:11 -04:00
|
|
|
})
|
2022-06-15 03:41:49 +02:00
|
|
|
|
|
|
|
|
afterEach(async () => {
|
|
|
|
|
await testHelper.cleanup()
|
|
|
|
|
})
|
|
|
|
|
|
2022-06-02 15:53:11 -04:00
|
|
|
it('should not throw', async () => {
|
2022-06-15 03:41:49 +02:00
|
|
|
const exitCode = await runContainerStep(runContainerStepData.args)
|
|
|
|
|
expect(exitCode).toBe(0)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should fail if the working directory does not exist', async () => {
|
|
|
|
|
runContainerStepData.args.workingDirectory = '/foo/bar'
|
|
|
|
|
await expect(runContainerStep(runContainerStepData.args)).rejects.toThrow()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should shold have env variables available', async () => {
|
|
|
|
|
runContainerStepData.args.entryPoint = 'bash'
|
|
|
|
|
runContainerStepData.args.entryPointArgs = [
|
|
|
|
|
'-c',
|
|
|
|
|
"'if [[ -z $NODE_ENV ]]; then exit 1; fi'"
|
|
|
|
|
]
|
2022-06-02 15:53:11 -04:00
|
|
|
await expect(
|
|
|
|
|
runContainerStep(runContainerStepData.args)
|
|
|
|
|
).resolves.not.toThrow()
|
|
|
|
|
})
|
|
|
|
|
})
|