Skip to content

Commit

Permalink
resouce/app_insights: Allow different application_type deployments (#…
Browse files Browse the repository at this point in the history
…1563)

Fixes: #822

This follows the work in the API to allow types like web, other, java,
store, phone and ios

```
▶ acctests azurerm TestAccAzureRMApplicationInsights_
=== RUN   TestAccAzureRMApplicationInsights_importBasicWeb
--- PASS: TestAccAzureRMApplicationInsights_importBasicWeb (99.07s)
=== RUN   TestAccAzureRMApplicationInsights_importBasicOther
--- PASS: TestAccAzureRMApplicationInsights_importBasicOther (96.48s)
=== RUN   TestAccAzureRMApplicationInsights_basicWeb
--- PASS: TestAccAzureRMApplicationInsights_basicWeb (84.27s)
=== RUN   TestAccAzureRMApplicationInsights_basicJava
--- PASS: TestAccAzureRMApplicationInsights_basicJava (79.28s)
=== RUN   TestAccAzureRMApplicationInsights_basicOther
--- PASS: TestAccAzureRMApplicationInsights_basicOther (73.29s)
=== RUN   TestAccAzureRMApplicationInsights_basicPhone
--- PASS: TestAccAzureRMApplicationInsights_basicPhone (73.88s)
=== RUN   TestAccAzureRMApplicationInsights_basicStore
--- PASS: TestAccAzureRMApplicationInsights_basicStore (68.69s)
=== RUN   TestAccAzureRMApplicationInsights_basiciOS
--- PASS: TestAccAzureRMApplicationInsights_basiciOS (76.30s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm	651.307s
```
  • Loading branch information
stack72 authored and tombuildsstuff committed Jul 13, 2018
1 parent fe4e024 commit d5deb91
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 26 deletions.
4 changes: 2 additions & 2 deletions azurerm/import_arm_application_insights_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestAccAzureRMApplicationInsights_importBasicWeb(t *testing.T) {
resourceName := "azurerm_application_insights.test"

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basicWeb(ri, testLocation())
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "web")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -35,7 +35,7 @@ func TestAccAzureRMApplicationInsights_importBasicOther(t *testing.T) {
resourceName := "azurerm_application_insights.test"

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basicWeb(ri, testLocation())
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "web")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down
8 changes: 6 additions & 2 deletions azurerm/resource_arm_application_insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ func resourceArmApplicationInsights() *schema.Resource {
ForceNew: true,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
ValidateFunc: validation.StringInSlice([]string{
string(insights.Web),
string(insights.Other),
"web",
"other",
"java",
"phone",
"store",
"ios",
}, true),
},

Expand Down
112 changes: 91 additions & 21 deletions azurerm/resource_arm_application_insights_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func TestAccAzureRMApplicationInsights_basicWeb(t *testing.T) {

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basicWeb(ri, testLocation())
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "web")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -24,6 +24,28 @@ func TestAccAzureRMApplicationInsights_basicWeb(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"),
resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "web"),
),
},
},
})
}

func TestAccAzureRMApplicationInsights_basicJava(t *testing.T) {

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "java")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMApplicationInsightsDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"),
resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "java"),
),
},
},
Expand All @@ -33,7 +55,7 @@ func TestAccAzureRMApplicationInsights_basicWeb(t *testing.T) {
func TestAccAzureRMApplicationInsights_basicOther(t *testing.T) {

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basicOther(ri, testLocation())
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "other")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -44,6 +66,70 @@ func TestAccAzureRMApplicationInsights_basicOther(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"),
resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "other"),
),
},
},
})
}

func TestAccAzureRMApplicationInsights_basicPhone(t *testing.T) {

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "phone")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMApplicationInsightsDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"),
resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "phone"),
),
},
},
})
}

func TestAccAzureRMApplicationInsights_basicStore(t *testing.T) {

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "store")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMApplicationInsightsDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"),
resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "store"),
),
},
},
})
}

func TestAccAzureRMApplicationInsights_basiciOS(t *testing.T) {

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "ios")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMApplicationInsightsDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"),
resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "ios"),
),
},
},
Expand Down Expand Up @@ -106,23 +192,7 @@ func testCheckAzureRMApplicationInsightsExists(name string) resource.TestCheckFu
}
}

func testAccAzureRMApplicationInsights_basicWeb(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_application_insights" "test" {
name = "acctestappinsights-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
application_type = "web"
}
`, rInt, location, rInt)
}

func testAccAzureRMApplicationInsights_basicOther(rInt int, location string) string {
func testAccAzureRMApplicationInsights_basic(rInt int, location string, applicationType string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand All @@ -133,7 +203,7 @@ resource "azurerm_application_insights" "test" {
name = "acctestappinsights-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
application_type = "other"
application_type = "%s"
}
`, rInt, location, rInt)
`, rInt, location, rInt, applicationType)
}
2 changes: 1 addition & 1 deletion website/docs/r/application_insights.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The following arguments are supported:

* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

* `application_type` - (Required) Specifies the type of Application Insights to create. Valid values are `Web` and `Other`.
* `application_type` - (Required) Specifies the type of Application Insights to create. Valid values are `Web`, `Java`, `Phone`, `Store`, `iOS` and `Other`.

* `tags` - (Optional) A mapping of tags to assign to the resource.

Expand Down

0 comments on commit d5deb91

Please sign in to comment.