Files
runner-container-hooks/packages/k8s/tests/run-container-step-test.ts
T

42 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-06-02 15:53:11 -04:00
import { runContainerStep } from '../src/hooks'
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', () => {
beforeEach(async () => {
2022-06-06 00:21:44 -04:00
testHelper = new TestHelper()
await testHelper.initialize()
runContainerStepData = testHelper.getRunContainerStepDefinition()
2022-06-02 15:53:11 -04:00
})
afterEach(async () => {
await testHelper.cleanup()
})
2022-06-02 15:53:11 -04:00
it('should not throw', async () => {
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()
})
})