Hi,
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 (
"fmt"
"testing"
"github.com/gruntwork-io/terratest/modules/azure"
"github.com/stretchr/testify/assert"
)
func TestWindowsvm(t *testing.T) {
t.Parallel()
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(testvmsize)
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)
}