Skip to content

Commit 8969b03

Browse files
author
Roman Bäriswyl
committed
Added test for labels with dockerfile
1 parent f475b2b commit 8969b03

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/test/cli.build.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Dev Containers CLI', function () {
2727

2828
describe('Command build', () => {
2929

30-
it('should build successfully with valid image metadata --label property', async () => {
30+
it('should build successfully with valid image metadata --label property (image)', async () => {
3131
const testFolder = `${__dirname}/configs/example`;
3232
const response = await shellExec(`${cli} build --workspace-folder ${testFolder} --label 'name=label-test' --label 'type=multiple-labels'`);
3333
const res = JSON.parse(response.stdout);
@@ -36,6 +36,15 @@ describe('Dev Containers CLI', function () {
3636
assert.match(labels.stdout.toString(), /\"name\": \"label-test\"/);
3737
});
3838

39+
it('should build successfully with valid image metadata --label property (dockerfile)', async () => {
40+
const testFolder = `${__dirname}/configs/example-dockerfile`;
41+
const response = await shellExec(`${cli} build --workspace-folder ${testFolder} --label 'name=label-test' --label 'type=multiple-labels'`);
42+
const res = JSON.parse(response.stdout);
43+
assert.equal(res.outcome, 'success');
44+
const labels = await shellExec(`docker inspect --format '{{json .Config.Labels}}' ${res.imageName} | jq`);
45+
assert.match(labels.stdout.toString(), /\"name\": \"label-test\"/);
46+
});
47+
3948
it('should fail to build with correct error message for local feature', async () => {
4049
const testFolder = `${__dirname}/configs/image-with-local-feature`;
4150
try {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Example devcontainer.json configuration with a Dockerfile
2+
{
3+
"build": {
4+
"dockerfile": "mcr.microsoft.com/devcontainers/base:latest"
5+
},
6+
"features": {
7+
"ghcr.io/devcontainers/features/go:1": {
8+
"version": "latest"
9+
}
10+
}
11+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#FROM dev-containers-docker-local.repo.pnet.ch/pf/additional/dev-container-build:1.0.202410310854
2+
FROM linux-docker-local.repo.pnet.ch/pf/debian:11.0.202410081002-bullseye

0 commit comments

Comments
 (0)