bake: add test for json vars and attributes

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
pull/541/head
Tonis Tiigi 4 years ago
parent 0fe2ce7fac
commit f036bba48c

@ -502,3 +502,14 @@ func TestHCLMultiFileAttrs(t *testing.T) {
require.Equal(t, c.Targets[0].Name, "app")
require.Equal(t, "pre-ghi", c.Targets[0].Args["v1"])
}
func TestJSONAttributes(t *testing.T) {
dt := []byte(`{"FOO": "abc", "variable": {"BAR": {"default": "def"}}, "target": { "app": { "args": {"v1": "pre-${FOO}-${BAR}"}} } }`)
c, err := ParseFile(dt, "docker-bake.json")
require.NoError(t, err)
require.Equal(t, 1, len(c.Targets))
require.Equal(t, c.Targets[0].Name, "app")
require.Equal(t, "pre-abc-def", c.Targets[0].Args["v1"])
}

Loading…
Cancel
Save