1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration/image/commit_test.go
Daniel Nephin 6be0f70983 Automated migration using
gty-migrate-from-testify --ignore-build-tags

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-16 11:03:43 -04:00

45 lines
1.4 KiB
Go

package image // import "github.com/docker/docker/integration/image"
import (
"context"
"testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/integration/internal/request"
"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
)
func TestCommitInheritsEnv(t *testing.T) {
defer setupTest(t)()
client := request.NewAPIClient(t)
ctx := context.Background()
cID1 := container.Create(t, ctx, client)
commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
Changes: []string{"ENV PATH=/bin"},
Reference: "test-commit-image",
})
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(t, ctx, client, container.WithImage(image1.ID))
commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
Changes: []string{"ENV PATH=/usr/bin:$PATH"},
Reference: "test-commit-image",
})
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))
}