c4e49d10 |
package daemon
import ( |
9a58f298 |
"fmt" |
c4e49d10 |
"io/ioutil"
"os"
"testing"
|
91e197d6 |
"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container" |
6bb0d181 |
"github.com/docker/docker/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,
} |
3c82fad4 |
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 |
a793564b |
container.SetRemovalInProgress() |
c4e49d10 |
|
9a58f298 |
// Try to remove the container when its state is removalInProgress.
// It should return an error indicating it is under removal progress.
if err := daemon.ContainerRm(container.ID, &types.ContainerRmConfig{ForceRemove: true}); err == nil {
t.Fatalf("expected err: %v, got nil", fmt.Sprintf("removal of container %s is already in progress", container.ID)) |
c4e49d10 |
}
} |