From 322b285122b2c79ed1b9cc925564a2ad7124166b Mon Sep 17 00:00:00 2001 From: Eric Black Date: Fri, 23 Aug 2024 11:03:32 -0700 Subject: [PATCH] Add test for missing dockerfile --- .../unit/commands/container/push.unit.test.ts | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/cli/test/unit/commands/container/push.unit.test.ts b/packages/cli/test/unit/commands/container/push.unit.test.ts index bd35470a11..80fa972000 100644 --- a/packages/cli/test/unit/commands/container/push.unit.test.ts +++ b/packages/cli/test/unit/commands/container/push.unit.test.ts @@ -1,4 +1,4 @@ -import {stdout} from 'stdout-stderr' +import {stdout, stderr} from 'stdout-stderr' import Cmd from '../../../../src/commands/container/push' import runCommand from '../../../helpers/runCommand' import {expect} from 'chai' @@ -198,6 +198,32 @@ describe('container push', function () { sandbox.assert.calledTwice(push) }) + it('warns when a specified Dockerfile is missing', async function () { + const dockerfiles = sandbox.stub(DockerHelper, 'getDockerfiles') + .returns(['/path/to/Dockerfile.web']) + const build = sandbox.stub(DockerHelper, 'buildImage') + build.withArgs('/path/to/Dockerfile.web', 'registry.heroku.com/testapp/web', []) + build.withArgs('/path/to/Dockerfile.worker', 'registry.heroku.com/testapp/worker', []) + const push = sandbox.stub(DockerHelper, 'pushImage') + push.withArgs('registry.heroku.com/testapp/web') + push.withArgs('registry.heroku.com/testapp/worker') + + await runCommand(Cmd, [ + '--app', + 'testapp', + '--recursive', + 'web', + 'worker', + ]) + + expect(stdout.output).to.contain('Building web (/path/to/Dockerfile.web)') + expect(stdout.output).to.contain('Pushing web (/path/to/Dockerfile.web)') + expect(stderr.output).to.contain('Dockerfile.worker not found') + sandbox.assert.calledOnce(dockerfiles) + sandbox.assert.calledOnce(build) + sandbox.assert.calledOnce(push) + }) + it('pushes all dockerfiles recursively when process types are not specified', async function () { const dockerfiles = sandbox.stub(DockerHelper, 'getDockerfiles') .returns(['/path/to/Dockerfile.web', '/path/to/Dockerfile.worker'])