github.com/rawahars/moby@v24.0.4+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 "gotest.tools/v3/assert" 11 "gotest.tools/v3/poll" 12 "gotest.tools/v3/skip" 13 ) 14 15 func TestDiff(t *testing.T) { 16 skip.If(t, testEnv.OSType == "windows", "FIXME") 17 defer setupTest(t)() 18 client := testEnv.APIClient() 19 ctx := context.Background() 20 21 cID := container.Run(ctx, t, client, container.WithCmd("sh", "-c", `mkdir /foo; echo xyzzy > /foo/bar`)) 22 23 // Wait for it to exit as cannot diff a running container on Windows, and 24 // it will take a few seconds to exit. Also there's no way in Windows to 25 // differentiate between an Add or a Modify, and all files are under 26 // a "Files/" prefix. 27 expected := []containertypes.FilesystemChange{ 28 {Kind: containertypes.ChangeAdd, Path: "/foo"}, 29 {Kind: containertypes.ChangeAdd, Path: "/foo/bar"}, 30 } 31 if testEnv.OSType == "windows" { 32 poll.WaitOn(t, container.IsInState(ctx, client, cID, "exited"), poll.WithDelay(100*time.Millisecond), poll.WithTimeout(60*time.Second)) 33 expected = []containertypes.FilesystemChange{ 34 {Kind: containertypes.ChangeModify, Path: "Files/foo"}, 35 {Kind: containertypes.ChangeModify, Path: "Files/foo/bar"}, 36 } 37 } 38 39 items, err := client.ContainerDiff(ctx, cID) 40 assert.NilError(t, err) 41 assert.DeepEqual(t, expected, items) 42 }