@@ -11,6 +11,15 @@ import (
1111 "github.com/hashicorp/terraform-plugin-sdk/terraform"
1212)
1313
14+ var firstLabelKey = "service"
15+ var secondLabelKey = "env"
16+ var topologyLabel = TopologyLabel {
17+ Data : map [string ][]string {
18+ firstLabelKey : {"collection-proxy" },
19+ secondLabelKey : {"dev" , "prod" },
20+ },
21+ }
22+
1423func TestAccSumologicDashboard_basic (t * testing.T ) {
1524 testNameSuffix := acctest .RandString (16 )
1625 title := "terraform_test_dashboard_" + testNameSuffix
@@ -41,8 +50,7 @@ func TestAccSumologicDashboard_create(t *testing.T) {
4150 description := "Test dashboard description"
4251 theme := "Dark"
4352 refreshInterval := 120
44- topologyLabel := "service"
45- topologyLabelValue := "collection-proxy"
53+
4654 literalRangeName := "today"
4755 textPanel := TextPanel {
4856 Key : "text-panel-001" ,
@@ -77,7 +85,7 @@ func TestAccSumologicDashboard_create(t *testing.T) {
7785 Steps : []resource.TestStep {
7886 {
7987 Config : dashboardCreateConfig (title , description , theme , refreshInterval ,
80- topologyLabel , topologyLabelValue , literalRangeName , textPanel , layout , variable ),
88+ topologyLabel , literalRangeName , textPanel , layout , variable ),
8189 Check : resource .ComposeTestCheckFunc (
8290 testAccCheckDashboardExists ("sumologic_dashboard.tf_crud_test" , & dashboard , t ),
8391 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
@@ -89,9 +97,7 @@ func TestAccSumologicDashboard_create(t *testing.T) {
8997 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
9098 "theme" , theme ),
9199 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
92- "topology_label_map.0.data.0.label" , topologyLabel ),
93- resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
94- "topology_label_map.0.data.0.values.0" , topologyLabelValue ),
100+ "topology_label_map.0.data.#" , "2" ),
95101 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
96102 "time_range.#" , "1" ),
97103 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
@@ -124,8 +130,6 @@ func TestAccSumologicDashboard_update(t *testing.T) {
124130 description := "Test dashboard description"
125131 theme := "Dark"
126132 refreshInterval := 120
127- topologyLabel := "service"
128- topologyLabelValue := "collection-proxy"
129133 literalRangeName := "today"
130134 textPanel := TextPanel {
131135 Key : "text-panel-001" ,
@@ -155,7 +159,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
155159 // updated config
156160 newTheme := "Light"
157161 newRefreshInterval := 300
158- newTopologyLabelValue := "collection-cluster"
162+ newFirstLabelValue := "collection-cluster"
159163 newLiteralRangeName := "week"
160164 searchPanel := SumoSearchPanel {
161165 Key : "search-panel-001" ,
@@ -207,7 +211,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
207211 Steps : []resource.TestStep {
208212 {
209213 Config : dashboardCreateConfig (title , description , theme , refreshInterval ,
210- topologyLabel , topologyLabelValue , literalRangeName , textPanel , layout , csvVariable ),
214+ topologyLabel , literalRangeName , textPanel , layout , csvVariable ),
211215 Check : resource .ComposeTestCheckFunc (
212216 testAccCheckDashboardExists ("sumologic_dashboard.tf_crud_test" , & dashboard , t ),
213217 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
@@ -217,7 +221,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
217221 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
218222 "theme" , theme ),
219223 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
220- "topology_label_map.0.data.0.values.0 " , topologyLabelValue ),
224+ "topology_label_map.0.data.# " , "2" ),
221225 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
222226 "time_range.0.begin_bounded_time_range.0.from.0.literal_time_range.0.range_name" ,
223227 literalRangeName ),
@@ -237,7 +241,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
237241 },
238242 {
239243 Config : dashboardUpdateConfig (title , description , newTheme , newRefreshInterval ,
240- topologyLabel , newTopologyLabelValue , newLiteralRangeName , textPanel , searchPanel ,
244+ firstLabelKey , newFirstLabelValue , newLiteralRangeName , textPanel , searchPanel ,
241245 newLayout , newVariables ),
242246 Check : resource .ComposeTestCheckFunc (
243247 testAccCheckDashboardExists ("sumologic_dashboard.tf_crud_test" , & dashboard , t ),
@@ -248,7 +252,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
248252 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
249253 "theme" , newTheme ),
250254 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
251- "topology_label_map.0.data.0.values.0 " , newTopologyLabelValue ),
255+ "topology_label_map.0.data.# " , "1" ),
252256 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
253257 "time_range.0.begin_bounded_time_range.0.from.0.literal_time_range.0.range_name" ,
254258 newLiteralRangeName ),
@@ -391,8 +395,8 @@ func dashboardImportConfig(title string) string {
391395}
392396
393397func dashboardCreateConfig (title string , description string , theme string , refreshInterval int ,
394- topologyLabel string , topologyLabelValue string , rangeName string , textPanel TextPanel ,
395- layout GridLayout , variable Variable ) string {
398+ topologyLabel TopologyLabel , rangeName string , textPanel TextPanel , layout GridLayout ,
399+ variable Variable ) string {
396400
397401 return fmt .Sprintf (`
398402 data "sumologic_personal_folder" "personalFolder" {}
@@ -407,6 +411,10 @@ func dashboardCreateConfig(title string, description string, theme string, refre
407411 label = "%s"
408412 values = ["%s"]
409413 }
414+ data {
415+ label = "%s"
416+ values = ["%s", "%s"]
417+ }
410418 }
411419 time_range {
412420 begin_bounded_time_range {
@@ -448,8 +456,9 @@ func dashboardCreateConfig(title string, description string, theme string, refre
448456 hide_from_ui = false
449457 }
450458 }` ,
451- title , description , refreshInterval , theme , topologyLabel , topologyLabelValue , rangeName ,
452- textPanel .Key , textPanel .Title , textPanel .Text ,
459+ title , description , refreshInterval , theme , firstLabelKey , topologyLabel .Data [firstLabelKey ][0 ],
460+ secondLabelKey , topologyLabel .Data [secondLabelKey ][0 ], topologyLabel .Data [secondLabelKey ][1 ],
461+ rangeName , textPanel .Key , textPanel .Title , textPanel .Text ,
453462 layout .LayoutStructures [0 ].Key , variable .Name , variable .DisplayName , variable .DefaultValue ,
454463 variable .SourceDefinition .(CsvVariableSourceDefinition ).Values ,
455464 )
0 commit comments