2

I' having this kind of issue: This is my test case to test against azure resource created or no.

    package test

import (
    "testing"
    "github.com/gruntwork-io/terratest/modules/azure"
    "github.com/stretchr/testify/assert"
)

func TestResourceGroupExists(t *testing.T) {
    resourceGroupName := "myResourceGroup"

    // Check if the resource group exists
    exists, err := azure.ResourceGroupExistsE(t, resourceGroupName)

    // Assert that there are no errors and the resource group exists
    assert.NoError(t, err)
    assert.True(t, exists, "Resource group does not exist.")
}

and when I'm executing this code via such command: [go test -v] I get this kind of error:

    ./main_test.go:14:44: cannot use t (variable of type *"testing".T) as type string in argument to azure.ResourceGroupExistsE
FAIL    terratest [build failed]

I have executed this command for installing the go dependencies. [go mod tidy]

Hayk Mkhitaryan
  • 388
  • 9
  • 26

1 Answers1

1

I solved it by myself this way:

    package test

import (
    "github.com/gruntwork-io/terratest/modules/azure"
    "github.com/stretchr/testify/assert"
    "testing"
)

func TestResourceGroupExists(t *testing.T) {
    resourceGroupName := "azresourcegroup1"
    subscriptionID := "f01d4840-68b4-47bc-8906-4f1ab8f03342"

    // Check if the resource group exists
    exists, err := azure.ResourceGroupExistsE(resourceGroupName, subscriptionID)

    // Assert that there are no errors and the resource group exists
    assert.NoError(t, err)
    assert.True(t, exists, "Resource group does not exist.")
}
Hayk Mkhitaryan
  • 388
  • 9
  • 26