packer-cn/driver/driver_test.go

40 lines
760 B
Go
Raw Normal View History

package driver
import (
"fmt"
2018-10-31 17:42:24 -04:00
"math/rand"
2018-10-30 18:10:57 -04:00
"os"
"testing"
"time"
)
// Defines whether acceptance tests should be run
const TestHostName = "esxi-1.vsphere65.test"
func newTestDriver(t *testing.T) *Driver {
2018-10-30 18:10:57 -04:00
username := os.Getenv("VSPHERE_USERNAME")
if username == "" {
username = "root"
}
password := os.Getenv("VSPHERE_PASSWORD")
if password == "" {
password = "jetbrains"
}
2018-05-16 09:53:32 -04:00
d, err := NewDriver(&ConnectConfig{
2018-01-23 14:51:05 -05:00
VCenterServer: "vcenter.vsphere65.test",
2018-10-30 18:10:57 -04:00
Username: username,
Password: password,
InsecureConnection: true,
})
if err != nil {
t.Fatalf("Cannot connect: %v", err)
}
return d
}
func newVMName() string {
rand.Seed(time.Now().UTC().UnixNano())
return fmt.Sprintf("test-%v", rand.Intn(1000))
}