mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
Merge pull request #2871 from jsternberg/bake-empty-variable-tests
bake: test empty override
This commit is contained in:
commit
0dfc4a1019
@ -2019,24 +2019,43 @@ target "app" {
|
||||
})
|
||||
}
|
||||
|
||||
// https://github.com/docker/buildx/pull/428
|
||||
// https://github.com/docker/buildx/issues/2822
|
||||
func TestEmptyAttribute(t *testing.T) {
|
||||
func TestVariableEmpty(t *testing.T) {
|
||||
fp := File{
|
||||
Name: "docker-bake.hcl",
|
||||
Data: []byte(`
|
||||
variable "FOO" {
|
||||
default = ""
|
||||
}
|
||||
target "app" {
|
||||
output = [""]
|
||||
output = [FOO]
|
||||
}
|
||||
`),
|
||||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
|
||||
m, _, err := ReadTargets(ctx, []File{fp}, []string{"app"}, nil, nil, &EntitlementConf{})
|
||||
require.Equal(t, 1, len(m))
|
||||
require.Len(t, m["app"].Outputs, 0)
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, m, "app")
|
||||
require.Len(t, m["app"].Outputs, 0)
|
||||
}
|
||||
|
||||
// https://github.com/docker/buildx/issues/2858
|
||||
func TestOverrideEmpty(t *testing.T) {
|
||||
fp := File{
|
||||
Name: "docker-bake.hcl",
|
||||
Data: []byte(`
|
||||
target "app" {
|
||||
output = ["./bin"]
|
||||
}
|
||||
`),
|
||||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
m, _, err := ReadTargets(ctx, []File{fp}, []string{"app"}, []string{"app.output="}, nil, &EntitlementConf{})
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, m, "app")
|
||||
require.Len(t, m["app"].Outputs, 0)
|
||||
}
|
||||
|
||||
func stringify[V fmt.Stringer](values []V) []string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user