Skip to content

Commit

Permalink
Fix acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GCHQDeveloper609 authored and tenthirtyam committed Nov 6, 2024
1 parent f9f3517 commit c048809
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/testhelper"
"github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/viapi"
"github.com/vmware/govmomi/vim25/types"
)

Expand Down Expand Up @@ -45,15 +46,32 @@ resource "vsphere_distributed_virtual_switch_pvlan_mapping" "mapping" {
secondary_vlan_id = 1005
pvlan_type = "promiscuous"
}
resource "vsphere_distributed_virtual_switch" "dvs" {
name = "testacc-dvs2"
datacenter_id = "${data.vsphere_datacenter.rootdc1.id}"
ignore_other_pvlan_mappings = true
host {
host_system_id = data.vsphere_host.roothost2.id
devices = ["%s"]
}
}
`,
testhelper.CombineConfigs(testAccResourceVSphereDistributedVirtualSwitchConfig()),
testhelper.CombineConfigs(testhelper.ConfigDataRootDC1(), testhelper.ConfigDataRootHost2()),
testhelper.HostNic0,
)
}

func testAccResourceVSphereDistributedVirtualSwitchPvlanMappingExists(expected bool) resource.TestCheckFunc {
return func(s *terraform.State) error {
props, err := testGetDVSProperties(s, "dvs")
if err != nil {
if viapi.IsAnyNotFoundError(err) && expected == false {
// Expected missing
return nil
}

return err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestAccResourceVSphereDistributedVirtualSwitch_basic(t *testing.T) {
ResourceName: "vsphere_distributed_virtual_switch.dvs",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"vlan_range"},
ImportStateVerifyIgnore: []string{"vlan_range", "ignore_other_pvlan_mappings"},
ImportStateIdFunc: func(s *terraform.State) (string, error) {
dvs, err := testGetDVS(s, "dvs")
if err != nil {
Expand Down

0 comments on commit c048809

Please sign in to comment.