Skip to content

Commit

Permalink
add tests for dedicated and zone redundant deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
jackofallops committed Aug 12, 2021
1 parent 76c3c0c commit cab7e86
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions internal/services/web/app_service_environment_v3_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,36 @@ func TestAccAppServiceEnvironmentV3_updateVnet(t *testing.T) {
})
}

func TestAccAppServiceEnvironmentV3_zoneRedundant(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_app_service_environment_v3", "test")
r := AppServiceEnvironmentV3Resource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.zoneRedundant(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccAppServiceEnvironmentV3_dedicatedHosts(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_app_service_environment_v3", "test")
r := AppServiceEnvironmentV3Resource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.dedicatedHosts(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (AppServiceEnvironmentV3Resource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.AppServiceEnvironmentID(state.ID)
if err != nil {
Expand Down Expand Up @@ -254,6 +284,34 @@ resource "azurerm_app_service_environment_v3" "import" {
`, template)
}

func (r AppServiceEnvironmentV3Resource) zoneRedundant(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
%s
resource "azurerm_app_service_environment_v3" "test" {
name = "acctest-ase-%d"
resource_group_name = azurerm_resource_group.test.name
subnet_id = azurerm_subnet.test.id
zone_redundant = true
}
`, template, data.RandomInteger)
}

func (r AppServiceEnvironmentV3Resource) dedicatedHosts(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
%s
resource "azurerm_app_service_environment_v3" "test" {
name = "acctest-ase-%d"
resource_group_name = azurerm_resource_group.test.name
subnet_id = azurerm_subnet.test.id
dedicated_host_count = 2
}
`, template, data.RandomInteger)
}



func (r AppServiceEnvironmentV3Resource) template(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down

0 comments on commit cab7e86

Please sign in to comment.