github.com/lacework-dev/go-moby@v20.10.12+incompatible/integration/container/diff_test.go (about) 1 package container // import "github.com/docker/docker/integration/container" 2 3 import ( 4 "context" 5 "testing" 6 "time" 7 8 containertypes "github.com/docker/docker/api/types/container" 9 "github.com/docker/docker/integration/internal/container" 10 "github.com/docker/docker/pkg/archive" 11 "gotest.tools/v3/assert" 12 "gotest.tools/v3/poll" 13 "gotest.tools/v3/skip" 14 ) 15 16 func TestDiff(t *testing.T) { 17 skip.If(t, testEnv.OSType == "windows", "FIXME") 18 defer setupTest(t)() 19 client := testEnv.APIClient() 20 ctx := context.Background() 21 22 cID := container.Run(ctx, t, client, container.WithCmd("sh", "-c", `mkdir /foo; echo xyzzy > /foo/bar`)) 23 24 // Wait for it to exit as cannot diff a running container on Windows, and 25 // it will take a few seconds to exit. Also there's no way in Windows to 26 // differentiate between an Add or a Modify, and all files are under 27 // a "Files/" prefix. 28 expected := []containertypes.ContainerChangeResponseItem{ 29 {Kind: archive.ChangeAdd, Path: "/foo"}, 30 {Kind: archive.ChangeAdd, Path: "/foo/bar"}, 31 } 32 if testEnv.OSType == "windows" { 33 poll.WaitOn(t, container.IsInState(ctx, client, cID, "exited"), poll.WithDelay(100*time.Millisecond), poll.WithTimeout(60*time.Second)) 34 expected = []containertypes.ContainerChangeResponseItem{ 35 {Kind: archive.ChangeModify, Path: "Files/foo"}, 36 {Kind: archive.ChangeModify, Path: "Files/foo/bar"}, 37 } 38 } 39 40 items, err := client.ContainerDiff(ctx, cID) 41 assert.NilError(t, err) 42 assert.DeepEqual(t, expected, items) 43 }