azure.GetSizeOfVirtualMachine(t, vmname, resourcegroup, "")

I’m having some real difficulty getting my simple terratest test to work. - code is below

The test gets the size of the VM, checks it against a string variable. expectedVMSize := “Standard_B2ms”

I’m using the function azure.GetSizeOfVirtualMachine to get the size of the VM. It works fine and returns the correct value - “Standard_B2ms”

When I run the compare using “assert.Equal” it fails even though the values are the same.

I think the reason that it errors, is because of the type. I have the expectedVMSize set as a string and the azure.GetSizeOfVirtualMachine gets set as a “compute.VirtualMachineSizeTypes” type?.

Can anyone help me, either to convert the compute.VirtualMachineSizeTypes to a string, or “pull” out the value of the compute.VirtualMachineSizeTypes so I can get the compare to work.

Or is there a way to get the assert.Equal to ignore the type and just check the values.
Code is below.
Many Thanks Russ

package TestWindowsvm

import (







func TestWindowsvm(t *testing.T) {


    dependenciesopts := &terraform.Options{

        TerraformDir: "./dependencies",

        VarFiles: []string{"testing.tfvars"},


    defer terraform.Destroy(t, dependenciesopts)

    terraform.InitAndApply(t, dependenciesopts)

    opts := &terraform.Options{

        TerraformDir: "./fixture",



    defer terraform.Destroy(t, opts)

    terraform.InitAndApply(t, opts)


    var vmname = "fo324o3400"

    var resourcegroup = "De32"

    testvmsize := azure.GetSizeOfVirtualMachine(t, vmname, resourcegroup, "")

    expectedVMSize := "Standard_B2ms"



    fmt.Println("This will hopefully be the actual size of the VM", testvmsize)

    fmt.Println("This will hopefully be the expected size of the VM", expectedVMSize)

    assert.Equal(t, expectedVMSize, testvmsize)



Hi russtym,

This is actually failing because GetSizeOfVirtualMachine returns a compute.VirtualMachineSizeTypes instead of a string, and you are comparing it against a string. It will work if you cast the expectedVMSize to the right type (like it is done in the example test).

Side note: please file a github issue on the terratest repo for Azure related questions in the future. Gruntwork doesn’t officially support Azure yet, and Azure support is actually maintained by collaborators from Microsoft. They won’t be watching this forum, so you will get faster and better responses if you file github issues. Thanks!

Best regards,

Hi Yoriy,
Again, thanks for replying and thanks for the example. Much appreciated.