github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/integration/image/commit_test.go (about) 1 package image // import "github.com/demonoid81/moby/integration/image" 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/demonoid81/moby/api/types" 8 "github.com/demonoid81/moby/api/types/versions" 9 "github.com/demonoid81/moby/integration/internal/container" 10 "gotest.tools/v3/assert" 11 is "gotest.tools/v3/assert/cmp" 12 "gotest.tools/v3/skip" 13 ) 14 15 func TestCommitInheritsEnv(t *testing.T) { 16 skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.36"), "broken in earlier versions") 17 skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME") 18 defer setupTest(t)() 19 client := testEnv.APIClient() 20 ctx := context.Background() 21 22 cID1 := container.Create(ctx, t, client) 23 24 commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{ 25 Changes: []string{"ENV PATH=/bin"}, 26 Reference: "test-commit-image", 27 }) 28 assert.NilError(t, err) 29 30 image1, _, err := client.ImageInspectWithRaw(ctx, commitResp1.ID) 31 assert.NilError(t, err) 32 33 expectedEnv1 := []string{"PATH=/bin"} 34 assert.Check(t, is.DeepEqual(expectedEnv1, image1.Config.Env)) 35 36 cID2 := container.Create(ctx, t, client, container.WithImage(image1.ID)) 37 38 commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{ 39 Changes: []string{"ENV PATH=/usr/bin:$PATH"}, 40 Reference: "test-commit-image", 41 }) 42 assert.NilError(t, err) 43 44 image2, _, err := client.ImageInspectWithRaw(ctx, commitResp2.ID) 45 assert.NilError(t, err) 46 expectedEnv2 := []string{"PATH=/usr/bin:/bin"} 47 assert.Check(t, is.DeepEqual(expectedEnv2, image2.Config.Env)) 48 }