mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
volume/local/TestCreateWithOpts(): use mount filter
This is not for the sake of test to run faster of course; this is to simplify the code as well as have some more testing for mount.SingleEntryFilter(). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
ac39a95ea6
commit
ce468f0ad0
1 changed files with 20 additions and 22 deletions
|
@ -184,6 +184,10 @@ func TestCreateWithOpts(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
t.Skip()
|
t.Skip()
|
||||||
}
|
}
|
||||||
|
if os.Getuid() != 0 {
|
||||||
|
t.Skip("root required")
|
||||||
|
}
|
||||||
|
|
||||||
rootDir, err := ioutil.TempDir("", "local-volume-test")
|
rootDir, err := ioutil.TempDir("", "local-volume-test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -215,15 +219,16 @@ func TestCreateWithOpts(t *testing.T) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
mountInfos, err := mount.GetMounts(nil)
|
mountInfos, err := mount.GetMounts(mount.SingleEntryFilter(dir))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if len(mountInfos) != 1 {
|
||||||
|
t.Fatalf("expected 1 mount, found %d: %+v", len(mountInfos), mountInfos)
|
||||||
|
}
|
||||||
|
|
||||||
var found bool
|
info := mountInfos[0]
|
||||||
for _, info := range mountInfos {
|
t.Logf("%+v", info)
|
||||||
if info.Mountpoint == dir {
|
|
||||||
found = true
|
|
||||||
if info.Fstype != "tmpfs" {
|
if info.Fstype != "tmpfs" {
|
||||||
t.Fatalf("expected tmpfs mount, got %q", info.Fstype)
|
t.Fatalf("expected tmpfs mount, got %q", info.Fstype)
|
||||||
}
|
}
|
||||||
|
@ -236,13 +241,6 @@ func TestCreateWithOpts(t *testing.T) {
|
||||||
if !strings.Contains(info.VfsOpts, "size=1024k") {
|
if !strings.Contains(info.VfsOpts, "size=1024k") {
|
||||||
t.Fatalf("expected mount info to have size=1024k: %q", info.VfsOpts)
|
t.Fatalf("expected mount info to have size=1024k: %q", info.VfsOpts)
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !found {
|
|
||||||
t.Fatal("mount not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
if v.active.count != 1 {
|
if v.active.count != 1 {
|
||||||
t.Fatalf("Expected active mount count to be 1, got %d", v.active.count)
|
t.Fatalf("Expected active mount count to be 1, got %d", v.active.count)
|
||||||
|
|
Loading…
Reference in a new issue