Skip to content

Commit

Permalink
azurerm_iothub & azurerm_iothub_certificate - fixing acctests (ha…
Browse files Browse the repository at this point in the history
…shicorp#27620)

* `azurerm_iothub` - fixing acctests
`azurerm_iothub_certificate` - fixing acctests

* update testing region for iothub

* typo
  • Loading branch information
ziyeqf authored Oct 17, 2024
1 parent f3a3c24 commit a38b708
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
5 changes: 4 additions & 1 deletion internal/services/iothub/iothub_certificate_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type IotHubCertificateResource struct{}

func TestAccIotHubCertificate_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub_certificate", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubCertificateResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -36,6 +37,7 @@ func TestAccIotHubCertificate_basic(t *testing.T) {

func TestAccIotHubCertificate_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub_certificate", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubCertificateResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -54,6 +56,7 @@ func TestAccIotHubCertificate_requiresImport(t *testing.T) {

func TestAccIotHubCertificate_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub_certificate", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubCertificateResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand Down Expand Up @@ -163,7 +166,7 @@ resource "azurerm_iothub" "test" {
}
resource "azurerm_iothub_certificate" "test" {
name = "acctestIoTCertificate-%d"
name = "acctestIoTHubCertificate-%d"
resource_group_name = azurerm_resource_group.test.name
iothub_name = azurerm_iothub.test.name
is_verified = true
Expand Down
37 changes: 30 additions & 7 deletions internal/services/iothub/iothub_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type IotHubResource struct{}

func TestAccIotHub_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -35,6 +36,7 @@ func TestAccIotHub_basic(t *testing.T) {

func TestAccIotHub_networkRulesSet(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -57,6 +59,7 @@ func TestAccIotHub_networkRulesSet(t *testing.T) {

func TestAccIotHub_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -75,6 +78,7 @@ func TestAccIotHub_requiresImport(t *testing.T) {

func TestAccIotHub_standard(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -90,6 +94,7 @@ func TestAccIotHub_standard(t *testing.T) {

func TestAccIotHub_customRoutes(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -113,6 +118,7 @@ func TestAccIotHub_customRoutes(t *testing.T) {

func TestAccIotHub_enrichments(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand Down Expand Up @@ -142,6 +148,7 @@ func TestAccIotHub_enrichments(t *testing.T) {

func TestAccIotHub_removeEndpointsAndRoutes(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -164,6 +171,7 @@ func TestAccIotHub_removeEndpointsAndRoutes(t *testing.T) {

func TestAccIotHub_fileUpload(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand Down Expand Up @@ -191,6 +199,7 @@ func TestAccIotHub_fileUpload(t *testing.T) {

func TestAccIotHub_fileUploadAuthenticationTypeUserAssignedIdentity(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -206,6 +215,7 @@ func TestAccIotHub_fileUploadAuthenticationTypeUserAssignedIdentity(t *testing.T

func TestAccIotHub_fileUploadAuthenticationTypeUpdate(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand Down Expand Up @@ -242,6 +252,7 @@ func TestAccIotHub_fileUploadAuthenticationTypeUpdate(t *testing.T) {

func TestAccIotHub_withDifferentEndpointResourceGroup(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -257,6 +268,7 @@ func TestAccIotHub_withDifferentEndpointResourceGroup(t *testing.T) {

func TestAccIotHub_fallbackRoute(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -275,6 +287,7 @@ func TestAccIotHub_fallbackRoute(t *testing.T) {

func TestAccIotHub_publicAccess(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand Down Expand Up @@ -311,6 +324,7 @@ func TestAccIotHub_publicAccess(t *testing.T) {

func TestAccIotHub_minTLSVersion(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -326,6 +340,7 @@ func TestAccIotHub_minTLSVersion(t *testing.T) {

func TestAccIotHub_LocalAuth(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Expand Down Expand Up @@ -356,6 +371,7 @@ func TestAccIotHub_LocalAuth(t *testing.T) {

func TestAccIotHub_cloudToDevice(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand Down Expand Up @@ -387,6 +403,7 @@ func TestAccIotHub_cloudToDevice(t *testing.T) {

func TestAccIotHub_identitySystemAssigned(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -402,6 +419,7 @@ func TestAccIotHub_identitySystemAssigned(t *testing.T) {

func TestAccIotHub_identitySystemAssignedUserAssigned(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -417,6 +435,7 @@ func TestAccIotHub_identitySystemAssignedUserAssigned(t *testing.T) {

func TestAccIotHub_identityUserAssigned(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -439,6 +458,7 @@ func TestAccIotHub_identityUserAssigned(t *testing.T) {

func TestAccIotHub_identityUpdate(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand Down Expand Up @@ -482,6 +502,7 @@ func TestAccIotHub_identityUpdate(t *testing.T) {

func TestAccIotHub_endpointAuthenticationTypeUserAssignedIdentity(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -497,6 +518,7 @@ func TestAccIotHub_endpointAuthenticationTypeUserAssignedIdentity(t *testing.T)

func TestAccIotHub_endpointAuthenticationTypeUpdate(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand Down Expand Up @@ -533,6 +555,7 @@ func TestAccIotHub_endpointAuthenticationTypeUpdate(t *testing.T) {

func TestAccIotHub_cosmosDBRouteUpdate(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")
data.Locations.Primary = "eastus" // iothub is only available on limited regions
r := IotHubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
Expand Down Expand Up @@ -1560,7 +1583,7 @@ resource "azurerm_iothub" "test" {
purpose = "testing"
}
}
`, data.RandomInteger, "eastus", data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func (IotHubResource) disableLocalAuth(data acceptance.TestData) string {
Expand Down Expand Up @@ -1593,7 +1616,7 @@ resource "azurerm_iothub" "test" {
purpose = "testing"
}
}
`, data.RandomInteger, "eastus", data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func (IotHubResource) enableLocalAuth(data acceptance.TestData) string {
Expand Down Expand Up @@ -1626,7 +1649,7 @@ resource "azurerm_iothub" "test" {
purpose = "testing"
}
}
`, data.RandomInteger, "eastus", data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func (IotHubResource) cloudToDevice(data acceptance.TestData) string {
Expand Down Expand Up @@ -2229,12 +2252,12 @@ provider "azurerm" {
resource "azurerm_resource_group" "iothub" {
name = "acctest-iothub-%[1]d"
location = "eastus"
location = "%[2]s"
}
resource "azurerm_resource_group" "endpoint" {
name = "acctest-iothub-db-%[1]d"
location = "eastus"
location = "%[2]s"
}
resource "azurerm_cosmosdb_account" "test" {
Expand Down Expand Up @@ -2278,7 +2301,7 @@ resource "azurerm_iothub" "test" {
capacity = "1"
}
%[2]s
%[3]s
}
resource "azurerm_iothub_endpoint_cosmosdb_account" "test" {
Expand All @@ -2303,5 +2326,5 @@ resource "azurerm_iothub_route" "test" {
enabled = false
depends_on = [azurerm_iothub_endpoint_cosmosdb_account.test]
}
`, data.RandomInteger, tagsBlock)
`, data.RandomInteger, data.Locations.Primary, tagsBlock)
}

0 comments on commit a38b708

Please sign in to comment.