Fix service port mappings when input is undefined, null, or empty (#60)

* fix: service without ports defined

* fix port mappings when ports are undefined,null or empty

* fix

Co-authored-by: Ronald Claveau <ronald.claveau@pennylane.com>
This commit is contained in:
Nikola Jokic
2023-01-06 11:54:52 +01:00
committed by GitHub
parent bf39b9bf16
commit 4448b61e00
3 changed files with 19 additions and 3 deletions

View File

@@ -82,4 +82,18 @@ describe('Prepare job', () => {
expect(services[0].command).toBe(undefined)
expect(services[0].args).toBe(undefined)
})
test.each([undefined, null, []])(
'should not throw exception when portMapping=%p',
async pm => {
prepareJobData.args.services.forEach(s => {
s.portMappings = pm
})
await prepareJob(prepareJobData.args, prepareJobOutputFilePath)
const content = JSON.parse(
fs.readFileSync(prepareJobOutputFilePath).toString()
)
expect(() => content.context.services[0].image).not.toThrow()
}
)
})