provider/vsphere: Randomize the vsphere_virtual_disk acceptance test

```
% make testacc TEST=./builtin/providers/vsphere TESTARGS='-run=TestAccVSphereVirtualDisk_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/27 18:08:08 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/vsphere -v -run=TestAccVSphereVirtualDisk_ -timeout 120m
=== RUN   TestAccVSphereVirtualDisk_basic
--- PASS: TestAccVSphereVirtualDisk_basic (8.57s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/vsphere	8.591s
```
This commit is contained in:
stack72 2017-03-27 18:09:12 +03:00
parent 9cf5395f86
commit 066eea4b35
No known key found for this signature in database
GPG Key ID: 8619A619B085CB16

View File

@ -6,6 +6,7 @@ import (
"os"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/vmware/govmomi"
@ -19,6 +20,8 @@ func TestAccVSphereVirtualDisk_basic(t *testing.T) {
var initTypeOpt string
var adapterTypeOpt string
rString := acctest.RandString(5)
if v := os.Getenv("VSPHERE_DATACENTER"); v != "" {
datacenterOpt = v
}
@ -39,14 +42,8 @@ func TestAccVSphereVirtualDisk_basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckVSphereVirtualDiskDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(
testAccCheckVSphereVirtuaDiskConfig_basic,
initTypeOpt,
adapterTypeOpt,
datacenterOpt,
datastoreOpt,
),
{
Config: testAccCheckVSphereVirtuaDiskConfig_basic(rString, initTypeOpt, adapterTypeOpt, datacenterOpt, datastoreOpt),
Check: resource.ComposeTestCheckFunc(
testAccVSphereVirtualDiskExists("vsphere_virtual_disk.foo"),
),
@ -119,13 +116,15 @@ func testAccCheckVSphereVirtualDiskDestroy(s *terraform.State) error {
return nil
}
const testAccCheckVSphereVirtuaDiskConfig_basic = `
func testAccCheckVSphereVirtuaDiskConfig_basic(rName, initTypeOpt, adapterTypeOpt, datacenterOpt, datastoreOpt string) string {
return fmt.Sprintf(`
resource "vsphere_virtual_disk" "foo" {
size = 1
vmdk_path = "tfTestDisk.vmdk"
vmdk_path = "tfTestDisk-%s.vmdk"
%s
%s
datacenter = "%s"
datastore = "%s"
}
`
`, rName, initTypeOpt, adapterTypeOpt, datacenterOpt, datastoreOpt)
}