Skip to content

Commit

Permalink
Added test for labels with dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Bäriswyl committed Nov 7, 2024
1 parent f475b2b commit 8969b03
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/test/cli.build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions src/test/configs/example-dockerfile/.devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
2 changes: 2 additions & 0 deletions src/test/configs/example-dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8969b03

Please sign in to comment.