From 060ad9bb1e4a06d83f1400049e4991c917441511 Mon Sep 17 00:00:00 2001 From: NilsBusche Date: Mon, 21 Sep 2020 10:26:26 +0200 Subject: [PATCH] windows_virtual_machine: Add test for updating license_type. --- ...ows_virtual_machine_resource_other_test.go | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/azurerm/internal/services/compute/tests/windows_virtual_machine_resource_other_test.go b/azurerm/internal/services/compute/tests/windows_virtual_machine_resource_other_test.go index 7f5907752b847..84efea5c8a276 100644 --- a/azurerm/internal/services/compute/tests/windows_virtual_machine_resource_other_test.go +++ b/azurerm/internal/services/compute/tests/windows_virtual_machine_resource_other_test.go @@ -367,6 +367,46 @@ func TestAccWindowsVirtualMachine_otherLicenseTypeWindowsServer(t *testing.T) { }) } +func TestAccWindowsVirtualMachine_otherLicenseTypeUpdated(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_windows_virtual_machine", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: checkWindowsVirtualMachineIsDestroyed, + Steps: []resource.TestStep{ + { + Config: testWindowsVirtualMachine_otherLicenseTypeDefault(data), + Check: resource.ComposeTestCheckFunc( + checkWindowsVirtualMachineExists(data.ResourceName), + ), + }, + data.ImportStep( + "admin_password", + ), + { + Config: testWindowsVirtualMachine_otherLicenseTypeWindowsClient(data), + Check: resource.ComposeTestCheckFunc( + checkWindowsVirtualMachineExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "license_type", "Windows_Client"), + ), + }, + data.ImportStep( + "admin_password", + ), + { + Config: testWindowsVirtualMachine_otherLicenseTypeDefault(data), + Check: resource.ComposeTestCheckFunc( + checkWindowsVirtualMachineExists(data.ResourceName), + ), + }, + data.ImportStep( + "admin_password", + ), + }, + }) +} + func TestAccWindowsVirtualMachine_otherPrioritySpot(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_windows_virtual_machine", "test") @@ -1208,6 +1248,37 @@ resource "azurerm_windows_virtual_machine" "test" { `, template) } +func testWindowsVirtualMachine_otherLicenseTypeDefault(data acceptance.TestData) string { + template := testWindowsVirtualMachine_template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_windows_virtual_machine" "test" { + name = local.vm_name + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + size = "Standard_F2" + admin_username = "adminuser" + admin_password = "P@$$w0rd1234!" + network_interface_ids = [ + azurerm_network_interface.test.id, + ] + + os_disk { + caching = "ReadWrite" + storage_account_type = "Standard_LRS" + } + + source_image_reference { + publisher = "MicrosoftWindowsDesktop" + offer = "Windows-10" + sku = "rs5-pro" + version = "latest" + } +} +`, template) +} + func testWindowsVirtualMachine_otherLicenseType(data acceptance.TestData, licenseType string) string { template := testWindowsVirtualMachine_template(data) return fmt.Sprintf(`