diff --git a/src/test/cli.build.test.ts b/src/test/cli.build.test.ts index 0dfae0427..1704c1f0d 100644 --- a/src/test/cli.build.test.ts +++ b/src/test/cli.build.test.ts @@ -27,7 +27,7 @@ describe('Dev Containers CLI', function () { describe('Command build', () => { - it('should build successfully with valid image metadata --label property', async () => { + it('should build successfully with valid image metadata --label property (image)', async () => { const testFolder = `${__dirname}/configs/example`; const response = await shellExec(`${cli} build --workspace-folder ${testFolder} --label 'name=label-test' --label 'type=multiple-labels'`); const res = JSON.parse(response.stdout); @@ -36,6 +36,15 @@ describe('Dev Containers CLI', function () { assert.match(labels.stdout.toString(), /\"name\": \"label-test\"/); }); + it('should build successfully with valid image metadata --label property (dockerfile)', async () => { + const testFolder = `${__dirname}/configs/example-dockerfile`; + const response = await shellExec(`${cli} build --workspace-folder ${testFolder} --label 'name=label-test' --label 'type=multiple-labels'`); + const res = JSON.parse(response.stdout); + assert.equal(res.outcome, 'success'); + const labels = await shellExec(`docker inspect --format '{{json .Config.Labels}}' ${res.imageName} | jq`); + assert.match(labels.stdout.toString(), /\"name\": \"label-test\"/); + }); + it('should fail to build with correct error message for local feature', async () => { const testFolder = `${__dirname}/configs/image-with-local-feature`; try { diff --git a/src/test/configs/example-dockerfile/.devcontainer.json b/src/test/configs/example-dockerfile/.devcontainer.json new file mode 100644 index 000000000..bc321b93d --- /dev/null +++ b/src/test/configs/example-dockerfile/.devcontainer.json @@ -0,0 +1,11 @@ +// Example devcontainer.json configuration with a Dockerfile +{ + "build": { + "dockerfile": "mcr.microsoft.com/devcontainers/base:latest" + }, + "features": { + "ghcr.io/devcontainers/features/go:1": { + "version": "latest" + } + } +} \ No newline at end of file diff --git a/src/test/configs/example-dockerfile/Dockerfile b/src/test/configs/example-dockerfile/Dockerfile new file mode 100644 index 000000000..3a98496f9 --- /dev/null +++ b/src/test/configs/example-dockerfile/Dockerfile @@ -0,0 +1,2 @@ +#FROM dev-containers-docker-local.repo.pnet.ch/pf/additional/dev-container-build:1.0.202410310854 +FROM linux-docker-local.repo.pnet.ch/pf/debian:11.0.202410081002-bullseye