Skip to content

Commit 2fee9fa

Browse files
committed
test(dashboard): add acceptance test for filter_variable_source_definition
1 parent ea86673 commit 2fee9fa

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

sumologic/resource_sumologic_dashboard_test.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,3 +652,92 @@ func dashboardUpdateConfig(title string, description string, theme string, refre
652652
variables[1].Name, variables[1].DisplayName, loqQuerySourceDef.Query, loqQuerySourceDef.Field,
653653
)
654654
}
655+
656+
func TestAccSumologicDashboard_filterSourceDefinition(t *testing.T) {
657+
testNameSuffix := acctest.RandString(16)
658+
659+
title := "terraform_test_dashboard_filter_" + testNameSuffix
660+
variableName := "_sourcecategory"
661+
variableDisplayName := "Source Category"
662+
filterKey := "_sourcecategory"
663+
filterValues := "aws/prod,aws/dev"
664+
filterPanelIds := "\"allpanels\""
665+
666+
resource.Test(t, resource.TestCase{
667+
PreCheck: func() { testAccPreCheck(t) },
668+
Providers: testAccProviders,
669+
CheckDestroy: testAccCheckDashboardDestroy(),
670+
Steps: []resource.TestStep{
671+
{
672+
Config: dashboardFilterSourceDefinitionConfig(title, variableName, variableDisplayName, filterKey, filterValues, filterPanelIds),
673+
Check: resource.ComposeTestCheckFunc(
674+
resource.TestCheckResourceAttr("sumologic_dashboard.tf_filter_test",
675+
"title", title),
676+
resource.TestCheckResourceAttr("sumologic_dashboard.tf_filter_test",
677+
"variable.0.name", variableName),
678+
resource.TestCheckResourceAttr("sumologic_dashboard.tf_filter_test",
679+
"variable.0.display_name", variableDisplayName),
680+
resource.TestCheckResourceAttr("sumologic_dashboard.tf_filter_test",
681+
"variable.0.source_definition.0.filter_variable_source_definition.0.key", filterKey),
682+
resource.TestCheckResourceAttr("sumologic_dashboard.tf_filter_test",
683+
"variable.0.source_definition.0.filter_variable_source_definition.0.values", filterValues),
684+
resource.TestCheckResourceAttr("sumologic_dashboard.tf_filter_test",
685+
"variable.0.source_definition.0.filter_variable_source_definition.0.panel_ids", filterPanelIds),
686+
),
687+
},
688+
},
689+
})
690+
}
691+
692+
func dashboardFilterSourceDefinitionConfig(title, variableName, variableDisplayName, filterKey, filterValues, filterPanelIds string) string {
693+
return fmt.Sprintf(`
694+
data "sumologic_personal_folder" "personalFolder" {}
695+
resource "sumologic_dashboard" "tf_filter_test" {
696+
title = "%s"
697+
folder_id = data.sumologic_personal_folder.personalFolder.id
698+
699+
time_range {
700+
begin_bounded_time_range {
701+
from {
702+
literal_time_range {
703+
range_name = "today"
704+
}
705+
}
706+
}
707+
}
708+
709+
panel {
710+
text_panel {
711+
key = "text-panel-01"
712+
title = "Test Panel"
713+
text = "Test text"
714+
}
715+
}
716+
717+
layout {
718+
grid {
719+
layout_structure {
720+
key = "text-panel-01"
721+
structure = "{\"height\":10,\"width\":24,\"x\":0,\"y\":0}"
722+
}
723+
}
724+
}
725+
726+
variable {
727+
name = "%s"
728+
display_name = "%s"
729+
source_definition {
730+
filter_variable_source_definition {
731+
key = "%s"
732+
values = "%s"
733+
panel_ids = "%s"
734+
}
735+
}
736+
allow_multi_select = true
737+
include_all_option = true
738+
hide_from_ui = false
739+
}
740+
}`,
741+
title, variableName, variableDisplayName, filterKey, filterValues, filterPanelIds,
742+
)
743+
}

0 commit comments

Comments
 (0)