c4e49d10 |
package daemon
import (
"io/ioutil"
"os"
"testing"
|
6bb0d181 |
"github.com/docker/docker/container" |
907407d0 |
"github.com/docker/engine-api/types"
containertypes "github.com/docker/engine-api/types/container" |
c4e49d10 |
)
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,
} |
c62c9636 |
daemon.containers = container.NewMemoryStore() |
c4e49d10 |
|
6bb0d181 |
container := &container.Container{
CommonContainer: container.CommonContainer{ |
4d1007d7 |
ID: "test", |
6bb0d181 |
State: container.NewState(), |
7ac4232e |
Config: &containertypes.Config{}, |
c4e49d10 |
},
} |
4d1007d7 |
daemon.containers.Add(container.ID, container) |
c4e49d10 |
// Mark the container as having a delete in progress |
6bb0d181 |
if err := container.SetRemovalInProgress(); err != nil { |
c4e49d10 |
t.Fatal(err)
}
// Try to remove the container when it's start is removalInProgress.
// It should ignore the container and not return an error. |
63fb931a |
if err := daemon.ContainerRm(container.ID, &types.ContainerRmConfig{ForceRemove: true}); err != nil { |
c4e49d10 |
t.Fatal(err)
}
} |