mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-29 17:05:46 +08:00
bake: add test for merging overrides
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
c05a6eb2c1
commit
0e4d7aa7a9
@ -274,7 +274,7 @@ services:
|
|||||||
|
|
||||||
func TestHCLCwdPrefix(t *testing.T) {
|
func TestHCLCwdPrefix(t *testing.T) {
|
||||||
fp := File{
|
fp := File{
|
||||||
Name: "docker-bake.hc",
|
Name: "docker-bake.hcl",
|
||||||
Data: []byte(
|
Data: []byte(
|
||||||
`target "app" {
|
`target "app" {
|
||||||
context = "cwd://foo"
|
context = "cwd://foo"
|
||||||
@ -295,3 +295,32 @@ func TestHCLCwdPrefix(t *testing.T) {
|
|||||||
require.Equal(t, "test", *m["app"].Dockerfile)
|
require.Equal(t, "test", *m["app"].Dockerfile)
|
||||||
require.Equal(t, "foo", *m["app"].Context)
|
require.Equal(t, "foo", *m["app"].Context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOverrideMerge(t *testing.T) {
|
||||||
|
fp := File{
|
||||||
|
Name: "docker-bake.hcl",
|
||||||
|
Data: []byte(
|
||||||
|
`target "app" {
|
||||||
|
platforms = ["linux/amd64"]
|
||||||
|
output = ["foo"]
|
||||||
|
}`),
|
||||||
|
}
|
||||||
|
ctx := context.TODO()
|
||||||
|
m, _, err := ReadTargets(ctx, []File{fp}, []string{"app"}, []string{
|
||||||
|
"app.platform=linux/arm",
|
||||||
|
"app.platform=linux/ppc64le",
|
||||||
|
"app.output=type=registry",
|
||||||
|
}, nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
require.Equal(t, 1, len(m))
|
||||||
|
_, ok := m["app"]
|
||||||
|
require.True(t, ok)
|
||||||
|
|
||||||
|
_, err = TargetsToBuildOpt(m, &Input{})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
require.Equal(t, []string{"linux/arm", "linux/ppc64le"}, m["app"].Platforms)
|
||||||
|
require.Equal(t, 1, len(m["app"].Outputs))
|
||||||
|
require.Equal(t, "type=registry", m["app"].Outputs[0])
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user