github.com/boynux/docker@v1.11.0-rc4/daemon/delete_test.go (about) 1 package daemon 2 3 import ( 4 "io/ioutil" 5 "os" 6 "testing" 7 8 "github.com/docker/docker/container" 9 "github.com/docker/engine-api/types" 10 containertypes "github.com/docker/engine-api/types/container" 11 ) 12 13 func TestContainerDoubleDelete(t *testing.T) { 14 tmp, err := ioutil.TempDir("", "docker-daemon-unix-test-") 15 if err != nil { 16 t.Fatal(err) 17 } 18 defer os.RemoveAll(tmp) 19 daemon := &Daemon{ 20 repository: tmp, 21 root: tmp, 22 } 23 daemon.containers = container.NewMemoryStore() 24 25 container := &container.Container{ 26 CommonContainer: container.CommonContainer{ 27 ID: "test", 28 State: container.NewState(), 29 Config: &containertypes.Config{}, 30 }, 31 } 32 daemon.containers.Add(container.ID, container) 33 34 // Mark the container as having a delete in progress 35 container.SetRemovalInProgress() 36 37 // Try to remove the container when it's start is removalInProgress. 38 // It should ignore the container and not return an error. 39 if err := daemon.ContainerRm(container.ID, &types.ContainerRmConfig{ForceRemove: true}); err != nil { 40 t.Fatal(err) 41 } 42 }