moby/daemon/delete_test.go
Michael Crosby 91e197d614 Add engine-api types to docker
This moves the types for the `engine-api` repo to the existing types
package.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-09-07 11:05:58 -07:00

42 lines
1 KiB
Go

package daemon
import (
"io/ioutil"
"os"
"testing"
"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/container"
)
func TestContainerDoubleDelete(t *testing.T) {
tmp, err := ioutil.TempDir("", "docker-daemon-unix-test-")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmp)
daemon := &Daemon{
repository: tmp,
root: tmp,
}
daemon.containers = container.NewMemoryStore()
container := &container.Container{
CommonContainer: container.CommonContainer{
ID: "test",
State: container.NewState(),
Config: &containertypes.Config{},
},
}
daemon.containers.Add(container.ID, container)
// Mark the container as having a delete in progress
container.SetRemovalInProgress()
// Try to remove the container when its start is removalInProgress.
// It should ignore the container and not return an error.
if err := daemon.ContainerRm(container.ID, &types.ContainerRmConfig{ForceRemove: true}); err != nil {
t.Fatal(err)
}
}