forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_source_app_service_plan_test.go
119 lines (103 loc) · 3.59 KB
/
data_source_app_service_plan_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccDataSourceAzureRMAppServicePlan_basic(t *testing.T) {
dataSourceName := "data.azurerm_app_service_plan.test"
rInt := acctest.RandInt()
location := testLocation()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceAppServicePlan_basic(rInt, location),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(dataSourceName, "kind", "Windows"),
resource.TestCheckResourceAttr(dataSourceName, "sku.#", "1"),
resource.TestCheckResourceAttr(dataSourceName, "sku.0.tier", "Basic"),
resource.TestCheckResourceAttr(dataSourceName, "sku.0.size", "B1"),
resource.TestCheckResourceAttr(dataSourceName, "properties.#", "1"),
resource.TestCheckResourceAttr(dataSourceName, "properties.0.per_site_scaling", "false"),
resource.TestCheckResourceAttr(dataSourceName, "tags.%", "0"),
),
},
},
})
}
func TestAccDataSourceAzureRMAppServicePlan_complete(t *testing.T) {
dataSourceName := "data.azurerm_app_service_plan.test"
rInt := acctest.RandInt()
location := testLocation()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceAppServicePlan_complete(rInt, location),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(dataSourceName, "kind", "Windows"),
resource.TestCheckResourceAttr(dataSourceName, "sku.#", "1"),
resource.TestCheckResourceAttr(dataSourceName, "sku.0.tier", "Standard"),
resource.TestCheckResourceAttr(dataSourceName, "sku.0.size", "S1"),
resource.TestCheckResourceAttr(dataSourceName, "properties.#", "1"),
resource.TestCheckResourceAttr(dataSourceName, "properties.0.per_site_scaling", "true"),
resource.TestCheckResourceAttr(dataSourceName, "tags.%", "1"),
resource.TestCheckResourceAttr(dataSourceName, "tags.environment", "Test"),
),
},
},
})
}
func testAccDataSourceAppServicePlan_basic(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_app_service_plan" "test" {
name = "acctestASP-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
tier = "Basic"
size = "B1"
}
}
data "azurerm_app_service_plan" "test" {
name = "${azurerm_app_service_plan.test.name}"
resource_group_name = "${azurerm_app_service_plan.test.resource_group_name}"
}
`, rInt, location, rInt)
}
func testAccDataSourceAppServicePlan_complete(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_app_service_plan" "test" {
name = "acctestASP-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
kind = "Windows"
sku {
tier = "Standard"
size = "S1"
}
properties {
per_site_scaling = true
}
tags {
environment = "Test"
}
}
data "azurerm_app_service_plan" "test" {
name = "${azurerm_app_service_plan.test.name}"
resource_group_name = "${azurerm_app_service_plan.test.resource_group_name}"
}
`, rInt, location, rInt)
}