-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
blueprint_definition_data_source_test.go
126 lines (106 loc) · 4.17 KB
/
blueprint_definition_data_source_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
120
121
122
123
124
125
126
package tests
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance"
)
// lintignore:AT001
func TestAccDataSourceBlueprintDefinition_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "data.azurerm_blueprint_definition", "test")
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceBlueprintDefinition_basic(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(data.ResourceName, "description", "Acceptance Test stub for Blueprints at Subscription"),
resource.TestCheckResourceAttr(data.ResourceName, "name", "testAcc_basicSubscription"),
resource.TestCheckResourceAttrSet(data.ResourceName, "last_modified"),
resource.TestCheckResourceAttr(data.ResourceName, "target_scope", "subscription"), // Only subscriptions can be targets
resource.TestCheckResourceAttrSet(data.ResourceName, "time_created"),
resource.TestCheckResourceAttr(data.ResourceName, "scope_type", "subscriptions"),
),
},
},
})
}
// lintignore:AT001
func TestAccDataSourceBlueprintDefinition_basicAtRootManagementGroup(t *testing.T) {
data := acceptance.BuildTestData(t, "data.azurerm_blueprint_definition", "test")
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceBlueprintDefinition_basicAtRootManagementGroup(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(data.ResourceName, "name", "testAcc_basicRootManagementGroup"),
resource.TestCheckResourceAttrSet(data.ResourceName, "time_created"),
resource.TestCheckResourceAttrSet(data.ResourceName, "last_modified"),
resource.TestCheckResourceAttr(data.ResourceName, "target_scope", "subscription"), // Only subscriptions can be targets
resource.TestCheckResourceAttr(data.ResourceName, "scope_type", "managementGroup"),
),
},
},
})
}
func TestAccDataSourceBlueprintDefinition_basicAtChildManagementGroup(t *testing.T) {
data := acceptance.BuildTestData(t, "data.azurerm_blueprint_definition", "test")
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceBlueprintDefinition_basicAtManagementGroup("testAcc_staticStubGroup"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(data.ResourceName, "name", "testAcc_staticStubManagementGroup"),
resource.TestCheckResourceAttrSet(data.ResourceName, "time_created"),
resource.TestCheckResourceAttrSet(data.ResourceName, "last_modified"),
resource.TestCheckResourceAttr(data.ResourceName, "target_scope", "subscription"), // Only subscriptions can be targets
resource.TestCheckResourceAttr(data.ResourceName, "scope_type", "managementGroup"),
),
},
},
})
}
func testAccDataSourceBlueprintDefinition_basic() string {
return `
provider "azurerm" {
features {}
}
data "azurerm_client_config" "current" {}
data "azurerm_blueprint_definition" "test" {
name = "testAcc_basicSubscription"
scope_type = "subscriptions"
scope_name = data.azurerm_client_config.current.subscription_id
}
`
}
func testAccDataSourceBlueprintDefinition_basicAtManagementGroup(managementGroup string) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
data "azurerm_client_config" "current" {}
data "azurerm_blueprint_definition" "test" {
name = "testAcc_staticStubManagementGroup"
scope_type = "managementGroup"
scope_name = "%s"
}
`, managementGroup)
}
func testAccDataSourceBlueprintDefinition_basicAtRootManagementGroup() string {
return `
provider "azurerm" {
features {}
}
data "azurerm_client_config" "current" {}
data "azurerm_blueprint_definition" "test" {
name = "testAcc_basicRootManagementGroup"
scope_type = "managementGroup"
scope_name = data.azurerm_client_config.current.tenant_id
}
`
}