Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resouce/app_insights: Allow different application_type deployments #1563

Merged
merged 1 commit into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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