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