moby/integration/image/commit_test.go
Brian Goff e8dc902781 Wire up tests to support otel tracing
Integration tests will now configure clients to propagate traces as well
as create spans for all tests.

Some extra changes were needed (or desired for trace propagation) in the
test helpers to pass through tracing spans via context.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2023-09-07 18:38:22 +00:00

49 lines
1.5 KiB
Go

package image // import "github.com/docker/docker/integration/image"
import (
"strings"
"testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/integration/internal/container"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/skip"
)
func TestCommitInheritsEnv(t *testing.T) {
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.36"), "broken in earlier versions")
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME")
ctx := setupTest(t)
client := testEnv.APIClient()
cID1 := container.Create(ctx, t, client)
imgName := strings.ToLower(t.Name())
commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
Changes: []string{"ENV PATH=/bin"},
Reference: imgName,
})
assert.NilError(t, err)
image1, _, err := client.ImageInspectWithRaw(ctx, commitResp1.ID)
assert.NilError(t, err)
expectedEnv1 := []string{"PATH=/bin"}
assert.Check(t, is.DeepEqual(expectedEnv1, image1.Config.Env))
cID2 := container.Create(ctx, t, client, container.WithImage(image1.ID))
commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
Changes: []string{"ENV PATH=/usr/bin:$PATH"},
Reference: imgName,
})
assert.NilError(t, err)
image2, _, err := client.ImageInspectWithRaw(ctx, commitResp2.ID)
assert.NilError(t, err)
expectedEnv2 := []string{"PATH=/usr/bin:/bin"}
assert.Check(t, is.DeepEqual(expectedEnv2, image2.Config.Env))
}