terratest assert.Equal not matching, can you get them to match?

1k views Asked by At

I'm new to writing terratest go tests. I have a simple test, where I want to check the VMSize, to make sure it has the correct size.

The function azure.GetSizeOfVirtualMachine() fetchs the value and stores it in a variable "testVMSize", then I have set another variable expectedVMSize := "Standard_B2ms" to compare it against.

finally I use testify/assert to compare the two values, if I print them out to the screen, they appear the same "Standard_B2ms" but when I run the assert.Equal it fails saying they are different. Output is below.

I can see that the types are different and I figure that is why they are failing. I was hoping someone could tell me how to change testVMSize so it matches the same type as they expectedVMSize or tell me how to get the value out of testVMSize so I could store it as a string type.

Thanks R

package TestWindowsvm

import (
    "fmt"
    "testing"
    "github.com/gruntwork-io/terratest/modules/azure"
    "github.com/gruntwork-io/terratest/modules/terraform"
    "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 = "fo35r00"
    var resourcegroup = "Dce"
    var subscriptionID ="2----3"
    

    testvmsize := azure.GetSizeOfVirtualMachine(t, vmname, resourcegroup, subscriptionID)
    
    expectedVMSize := "Standard_B2ms"
    fmt.Println(testvmsize)

     assert.Equal(t, expectedVMSize, testvmsize )
    
}

This is the Error Message

        Error:          Not equal:
                        expected: string("Standard_B2ms")
                        actual  : compute.VirtualMachineSizeTypes("Standard_B2ms")
0

There are 0 answers