bake: TestEmptyVariable

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
(cherry picked from commit 291c353575)
This commit is contained in:
CrazyMax 2025-05-21 16:15:30 +02:00
parent 257423c323
commit d364dfeefc
No known key found for this signature in database
GPG Key ID: ADE44D8C9D44FBE4
1 changed files with 14 additions and 0 deletions

View File

@ -1622,6 +1622,20 @@ target "two" {
require.Equal(t, map[string]*string{"b": ptrstr("pre-jkl")}, c.Targets[1].Args)
}
func TestEmptyVariable(t *testing.T) {
dt := []byte(`
variable "FOO" {}
target "default" {
args = {
foo = equal(FOO, "")
}
}`)
c, err := ParseFile(dt, "docker-bake.hcl")
require.NoError(t, err)
require.Equal(t, 1, len(c.Targets))
require.Equal(t, "true", *c.Targets[0].Args["foo"])
}
func TestEmptyVariableJSON(t *testing.T) {
dt := []byte(`{
"variable": {