Skip to content

Commit 2b48688

Browse files
aledbfclaude
andcommitted
test(docker): hold StageLabels of a named stage
Mutation testing found that no test held the stage-by-name lookup behind StageLabels, which keeps a user's metadata label of the targeted stage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 130100b commit 2b48688

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎internal/docker/dockerfile_test.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,14 @@ func TestStageLabelsDevcontainerMetadata(t *testing.T) {
101101
t.Errorf("unexpected devcontainer.metadata = %q", v)
102102
}
103103
}
104+
105+
// A named stage's labels are its own, not the final stage's.
106+
func TestStageLabelsOfANamedStage(t *testing.T) {
107+
df := ExtractDockerfile("FROM alpine AS base\nLABEL a=base\nFROM base\nLABEL a=final\n")
108+
if got := df.StageLabels("base")["a"]; got != "base" {
109+
t.Errorf("base stage label a = %q, want base", got)
110+
}
111+
if got := df.StageLabels("")["a"]; got != "final" {
112+
t.Errorf("final stage label a = %q, want final", got)
113+
}
114+
}

0 commit comments

Comments
 (0)