mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
442b45628e
Adds support for the daemon to handle user namespace maps as a per-daemon setting. Support for handling uid/gid mapping is added to the builder, archive/unarchive packages and functions, all graphdrivers (except Windows), and the test suite is updated to handle user namespace daemon rootgraph changes. Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
81 lines
1.3 KiB
Go
81 lines
1.3 KiB
Go
package local
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestRemove(t *testing.T) {
|
|
rootDir, err := ioutil.TempDir("", "local-volume-test")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer os.RemoveAll(rootDir)
|
|
|
|
r, err := New(rootDir, 0, 0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
vol, err := r.Create("testing", nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if err := r.Remove(vol); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
vol, err = r.Create("testing2", nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.RemoveAll(vol.Path()); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if err := r.Remove(vol); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if _, err := os.Stat(vol.Path()); err != nil && !os.IsNotExist(err) {
|
|
t.Fatal("volume dir not removed")
|
|
}
|
|
|
|
if len(r.List()) != 0 {
|
|
t.Fatal("expected there to be no volumes")
|
|
}
|
|
}
|
|
|
|
func TestInitializeWithVolumes(t *testing.T) {
|
|
rootDir, err := ioutil.TempDir("", "local-volume-test")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer os.RemoveAll(rootDir)
|
|
|
|
r, err := New(rootDir, 0, 0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
vol, err := r.Create("testing", nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
r, err = New(rootDir, 0, 0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
v, err := r.Get(vol.Name())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if v.Path() != vol.Path() {
|
|
t.Fatal("expected to re-initialize root with existing volumes")
|
|
}
|
|
}
|