check folder in default test

This commit is contained in:
Michael Kuzmin 2017-08-24 01:39:14 +03:00
parent 3acf445d98
commit 1bf942a2c2
1 changed files with 14 additions and 6 deletions

View File

@ -42,7 +42,7 @@ func checkDefault(t *testing.T, name string, host string) builderT.TestCheckFunc
d := testConn(t) d := testConn(t)
vm := getVM(t, d, artifacts) vm := getVM(t, d, artifacts)
vmInfo, err := d.VMInfo(vm, "name", "runtime.host", "resourcePool", "layoutEx.disk") vmInfo, err := d.VMInfo(vm, "name", "parent", "runtime.host", "resourcePool", "layoutEx.disk")
if err != nil { if err != nil {
t.Fatalf("Cannot read VM properties: %v", err) t.Fatalf("Cannot read VM properties: %v", err)
} }
@ -51,6 +51,15 @@ func checkDefault(t *testing.T, name string, host string) builderT.TestCheckFunc
t.Errorf("Invalid VM name: expected '%v', got '%v'", name, vmInfo.Name) t.Errorf("Invalid VM name: expected '%v', got '%v'", name, vmInfo.Name)
} }
f := d.NewFolder(vmInfo.Parent)
folderPath, err := d.GetFolderPath(f)
if err != nil {
t.Fatalf("Cannot read folder name: %v", err)
}
if folderPath != "" {
t.Errorf("Invalid folder: expected '/', got '%v'", folderPath)
}
h := d.NewHost(vmInfo.Runtime.Host) h := d.NewHost(vmInfo.Runtime.Host)
hostInfo, err := d.HostInfo(h, "name") hostInfo, err := d.HostInfo(h, "name")
if err != nil { if err != nil {
@ -62,13 +71,12 @@ func checkDefault(t *testing.T, name string, host string) builderT.TestCheckFunc
} }
p := d.NewResourcePool(vmInfo.ResourcePool) p := d.NewResourcePool(vmInfo.ResourcePool)
poolInfo, err := d.ResourcePoolInfo(p, "owner", "parent") poolPath, err := d.GetResourcePoolPath(p)
if err != nil { if err != nil {
t.Fatalf("Cannot read resource pool properties: %v", err) t.Fatalf("Cannot read resource pool name: %v", err)
} }
if poolPath != "" {
if poolInfo.Owner != *poolInfo.Parent { t.Error("Invalid resource pool: expected '/', got '%v'", poolPath)
t.Error("Not a root resource pool")
} }
if len(vmInfo.LayoutEx.Disk[0].Chain) != 1 { if len(vmInfo.LayoutEx.Disk[0].Chain) != 1 {