Skip to content

Commit

Permalink
windows_virtual_machine: Add test for updating license_type.
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsBusche committed Sep 21, 2020
1 parent 76e1d68 commit 060ad9b
Showing 1 changed file with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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(`
Expand Down

0 comments on commit 060ad9b

Please sign in to comment.