Fix unit-tests
Upstream-commit: 12e993549df025d072add1a0bcb9bfcc7fe5bdb5 Component: engine
This commit is contained in:
@ -1676,67 +1676,3 @@ func TestRestartGhost(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoveFile(t *testing.T) {
|
||||
runtime := mkRuntime(t)
|
||||
defer nuke(runtime)
|
||||
|
||||
container1, _ := mkContainer(runtime, []string{"_", "/bin/sh", "-c", "touch test.txt"}, t)
|
||||
defer runtime.Destroy(container1)
|
||||
|
||||
if container1.State.Running {
|
||||
t.Errorf("Container shouldn't be running")
|
||||
}
|
||||
if err := container1.Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if container1.State.Running {
|
||||
t.Errorf("Container shouldn't be running")
|
||||
}
|
||||
|
||||
commit := func(container *Container) (*Image, error) {
|
||||
rwTar, err := container.ExportRw()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
img, err := runtime.graph.Create(rwTar, container, "unit test commited image", "", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return img, nil
|
||||
}
|
||||
|
||||
img, err := commit(container1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
container2, _ := mkContainer(runtime, []string{img.ID, "/bin/sh", "-c", "rm /test.txt"}, t)
|
||||
defer runtime.Destroy(container2)
|
||||
|
||||
if err := container2.Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
containerMount, err := runtime.driver.Get(container2.ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Stat(path.Join(containerMount, "test.txt")); err == nil {
|
||||
t.Fatalf("test.txt should not exist")
|
||||
}
|
||||
|
||||
img, err = commit(container2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
mountPoint, err := runtime.driver.Get(img.ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
file := path.Join(mountPoint, "test.txt")
|
||||
if _, err := os.Stat(file); err == nil {
|
||||
t.Fatalf("The file %s should not exist\n", file)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user