Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test for labels with dockerfile #929

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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