Add an acceptance test for `driver.Folder`
This commit is contained in:
parent
d33ffc178d
commit
23c6951aa4
|
@ -91,13 +91,7 @@ func checkFolder(t *testing.T, folder string) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
f := d.NewFolder(vmInfo.Parent)
|
||||
path, err := f.Path()
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot read folder name: %v", err)
|
||||
}
|
||||
if path != folder {
|
||||
t.Errorf("Wrong folder. expected: %v, got: %v", folder, path)
|
||||
}
|
||||
driverT.CheckFolderPath(t, f, folder)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package testing
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestFolderAcc(t *testing.T) {
|
||||
initDriverAcceptanceTest(t)
|
||||
|
||||
d := NewTestDriver(t)
|
||||
f, err := d.FindFolder(TestFolder)
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot find the default folder '%v': %v", TestFolder, err)
|
||||
}
|
||||
CheckFolderPath(t, f, TestFolder)
|
||||
}
|
|
@ -7,7 +7,6 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
"github.com/vmware/govmomi/govc/pool"
|
||||
)
|
||||
|
||||
func NewTestDriver(t *testing.T) *driver.Driver {
|
||||
|
@ -28,12 +27,12 @@ func NewVMName() string {
|
|||
return fmt.Sprintf("test-%v", rand.Intn(1000))
|
||||
}
|
||||
|
||||
func CheckDatastoreName(t *testing.T, ds *driver.Datastore, name string) {
|
||||
func CheckDatastoreName(t *testing.T, ds *driver.Datastore, datastore string) {
|
||||
switch info, err := ds.Info("name"); {
|
||||
case err != nil:
|
||||
t.Errorf("Cannot read datastore properties: %v", err)
|
||||
case info.Name != name:
|
||||
t.Errorf("Wrong datastore. expected: %v, got: %v", name, info.Name)
|
||||
case info.Name != datastore:
|
||||
t.Errorf("Wrong datastore. expected: %v, got: %v", datastore, info.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,6 +45,15 @@ func CheckResourcePoolPath(t *testing.T, p *driver.ResourcePool, pool string) {
|
|||
}
|
||||
}
|
||||
|
||||
func CheckFolderPath(t *testing.T, f *driver.Folder, folder string) {
|
||||
switch path, err := f.Path(); {
|
||||
case err != nil:
|
||||
t.Fatalf("Cannot read folder name: %v", err)
|
||||
case path != folder:
|
||||
t.Errorf("Wrong folder. expected: %v, got: %v", folder, path)
|
||||
}
|
||||
}
|
||||
|
||||
func initDriverAcceptanceTest(t *testing.T) {
|
||||
// We only run acceptance tests if an env var is set because they're
|
||||
// slow and require outside configuration.
|
||||
|
|
Loading…
Reference in New Issue