Skip to content

Commit

Permalink
test: revert non-deterministic compose context path
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Jan 31, 2024
1 parent 13beda8 commit 5130700
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
15 changes: 3 additions & 12 deletions bake/bake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,6 @@ services:

ctx := context.TODO()

cwd, err := os.Getwd()
require.NoError(t, err)

m, g, err := ReadTargets(ctx, []File{fp, fp2, fp3}, []string{"default"}, nil, nil)
require.NoError(t, err)

Expand All @@ -308,7 +305,7 @@ services:

require.True(t, ok)
require.Equal(t, "Dockerfile.webapp", *m["webapp"].Dockerfile)
require.Equal(t, cwd, *m["webapp"].Context)
require.Equal(t, ".", *m["webapp"].Context)
require.Equal(t, ptrstr("1"), m["webapp"].Args["buildno"])
require.Equal(t, ptrstr("12"), m["webapp"].Args["buildno2"])

Expand Down Expand Up @@ -347,9 +344,6 @@ services:

ctx := context.TODO()

cwd, err := os.Getwd()
require.NoError(t, err)

m, _, err := ReadTargets(ctx, []File{fp}, []string{"web.app"}, nil, nil)
require.NoError(t, err)
require.Equal(t, 1, len(m))
Expand All @@ -372,7 +366,7 @@ services:
_, ok = m["web_app"]
require.True(t, ok)
require.Equal(t, "Dockerfile.webapp", *m["web_app"].Dockerfile)
require.Equal(t, cwd, *m["web_app"].Context)
require.Equal(t, ".", *m["web_app"].Context)
require.Equal(t, ptrstr("1"), m["web_app"].Args["buildno"])
require.Equal(t, ptrstr("12"), m["web_app"].Args["buildno2"])

Expand Down Expand Up @@ -581,9 +575,6 @@ services:

ctx := context.TODO()

cwd, err := os.Getwd()
require.NoError(t, err)

m, _, err := ReadTargets(ctx, []File{fp, fp2}, []string{"app1", "app2"}, nil, nil)
require.NoError(t, err)

Expand All @@ -596,7 +587,7 @@ services:
require.Equal(t, "Dockerfile", *m["app1"].Dockerfile)
require.Equal(t, ".", *m["app1"].Context)
require.Equal(t, "Dockerfile", *m["app2"].Dockerfile)
require.Equal(t, cwd, *m["app2"].Context)
require.Equal(t, ".", *m["app2"].Context)
}

func TestReadContextFromTargetChain(t *testing.T) {
Expand Down
11 changes: 4 additions & 7 deletions bake/compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ secrets:
file: /root/.aws/credentials
`)

cwd, err := os.Getwd()
require.NoError(t, err)

c, err := ParseCompose([]composetypes.ConfigFile{{Content: dt}}, nil)
require.NoError(t, err)

Expand All @@ -65,12 +62,12 @@ secrets:
return c.Targets[i].Name < c.Targets[j].Name
})
require.Equal(t, "db", c.Targets[0].Name)
require.Equal(t, filepath.Join(cwd, "db"), *c.Targets[0].Context)
require.Equal(t, "db", *c.Targets[0].Context)
require.Equal(t, []string{"docker.io/tonistiigi/db"}, c.Targets[0].Tags)

require.Equal(t, "webapp", c.Targets[1].Name)
require.Equal(t, filepath.Join(cwd, "dir"), *c.Targets[1].Context)
require.Equal(t, map[string]string{"foo": filepath.Join(cwd, "bar")}, c.Targets[1].Contexts)
require.Equal(t, "dir", *c.Targets[1].Context)
require.Equal(t, map[string]string{"foo": "bar"}, c.Targets[1].Contexts)
require.Equal(t, "Dockerfile-alternate", *c.Targets[1].Dockerfile)
require.Equal(t, 1, len(c.Targets[1].Args))
require.Equal(t, ptrstr("123"), c.Targets[1].Args["buildno"])
Expand All @@ -83,7 +80,7 @@ secrets:
}, c.Targets[1].Secrets)

require.Equal(t, "webapp2", c.Targets[2].Name)
require.Equal(t, filepath.Join(cwd, "dir"), *c.Targets[2].Context)
require.Equal(t, "dir", *c.Targets[2].Context)
require.Equal(t, "FROM alpine\n", *c.Targets[2].DockerfileInline)
}

Expand Down

0 comments on commit 5130700

Please sign in to comment.