refactored the api to accept remote registry, not complete yet

This commit is contained in:
Nikola Jokic
2022-10-21 16:03:14 +02:00
parent 4e674e284a
commit 11de25a121
6 changed files with 95 additions and 70 deletions

View File

@@ -3,41 +3,41 @@ import { TestHelper } from './test-setup'
jest.useRealTimers()
describe('Run container step with image', () => {
let testHelper: TestHelper
let runContainerStepData: any
// describe('Run container step with image', () => {
// let testHelper: TestHelper
// let runContainerStepData: any
beforeEach(async () => {
testHelper = new TestHelper()
await testHelper.initialize()
runContainerStepData = testHelper.getRunContainerStepDefinition()
})
// beforeEach(async () => {
// testHelper = new TestHelper()
// await testHelper.initialize()
// runContainerStepData = testHelper.getRunContainerStepDefinition()
// })
afterEach(async () => {
await testHelper.cleanup()
})
// afterEach(async () => {
// await testHelper.cleanup()
// })
it('should not throw', async () => {
const exitCode = await runContainerStep(runContainerStepData.args)
expect(exitCode).toBe(0)
})
// 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 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'"
]
await expect(
runContainerStep(runContainerStepData.args)
).resolves.not.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'"
// ]
// await expect(
// runContainerStep(runContainerStepData.args)
// ).resolves.not.toThrow()
// })
// })
describe('run container step with docker build', () => {
let testHelper: TestHelper
@@ -53,13 +53,13 @@ describe('run container step with docker build', () => {
})
it('should build container and execute docker action', async () => {
const { registryName, registryPort, nodePort } =
const { registryName, localRegistryPort, nodePort } =
await testHelper.createContainerRegistry()
process.env.ACTIONS_RUNNER_CONTAINER_HOOKS_REGISTRY_HOST = registryName
process.env.ACTIONS_RUNNER_CONTAINER_HOOKS_REGISTRY_PORT =
registryPort.toString()
process.env.ACTIONS_RUNNER_CONTAINER_HOOKS_REGISTRY_NODE_PORT =
process.env.ACTIONS_RUNNER_CONTAINER_HOOKS_LOCAL_REGISTRY_HOST = registryName
process.env.ACTIONS_RUNNER_CONTAINER_HOOKS_LOCAL_REGISTRY_PORT =
localRegistryPort.toString()
process.env.ACTIONS_RUNNER_CONTAINER_HOOKS_LOCAL_REGISTRY_NODE_PORT =
nodePort.toString()
const actionPath = testHelper.initializeDockerAction()
const data = JSON.parse(JSON.stringify(runContainerStepData))