-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
r/virtual_machine: Remove OOB deleted virtual machines from state #321
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,41 @@ func TestAccResourceVSphereVirtualMachine(t *testing.T) { | |
}, | ||
}, | ||
}, | ||
{ | ||
"re-create on deletion", | ||
resource.TestCase{ | ||
PreCheck: func() { | ||
testAccPreCheck(tp) | ||
testAccResourceVSphereVirtualMachinePreCheck(tp) | ||
}, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccResourceVSphereVirtualMachineCheckExists(false), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccResourceVSphereVirtualMachineConfigBasic(), | ||
Check: resource.ComposeTestCheckFunc( | ||
copyState(&state), | ||
testAccResourceVSphereVirtualMachineCheckExists(true), | ||
), | ||
}, | ||
{ | ||
PreConfig: func() { | ||
if err := testDeleteVM(state, "vm"); err != nil { | ||
panic(err) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe it's just and Azure provider thing - but we'd generally make the deletion a Check function and assert it's been deleted, rather than crashing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update: The intention here is to make sure this gets handled completely outside of the plan/apply testing cycle. What would be nicer is if the signature of |
||
}, | ||
Config: testAccResourceVSphereVirtualMachineConfigBasic(), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccResourceVSphereVirtualMachineCheckExists(true), | ||
func(s *terraform.State) error { | ||
oldID := state.RootModule().Resources["vsphere_virtual_machine.vm"].Primary.ID | ||
return testCheckResourceNotAttr("vsphere_virtual_machine.vm", "id", oldID)(s) | ||
}, | ||
), | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
"multi-device", | ||
resource.TestCase{ | ||
|
@@ -2107,7 +2142,7 @@ resource "vsphere_virtual_machine" "vm" { | |
num_cpus = 2 | ||
memory = 2048 | ||
guest_id = "other3xLinux64Guest" | ||
|
||
network_interface { | ||
network_id = "${data.vsphere_network.network.id}" | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth making this
message
to be self-explanatory?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an internal field on a very small object - and this generally matches the pattern you see in something like the
errors
package, so I think it's fine :)