@@ -11,8 +11,8 @@ import (
1111 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
1212)
1313
14- // Dashboard API is in technical preview and available from 9.3 .x onwards
15- var minDashboardAPISupport = version .Must (version .NewVersion ("9.3 .0-SNAPSHOT" ))
14+ // Dashboard API is in technical preview and available from 9.4 .x onwards
15+ var minDashboardAPISupport = version .Must (version .NewVersion ("9.4 .0-SNAPSHOT" ))
1616
1717func TestAccResourceEmptyDashboard (t * testing.T ) {
1818 dashboardTitle := "Test Dashboard " + sdkacctest .RandStringFromCharSet (4 , sdkacctest .CharSetAlphaNum )
@@ -395,3 +395,45 @@ func TestAccResourceDashboardXYChart(t *testing.T) {
395395 },
396396 })
397397}
398+
399+ func TestAccResourceDashboardGaugeChart (t * testing.T ) {
400+ dashboardTitle := "Test Dashboard with Gauge Chart " + sdkacctest .RandStringFromCharSet (4 , sdkacctest .CharSetAlphaNum )
401+
402+ resource .Test (t , resource.TestCase {
403+ PreCheck : func () { acctest .PreCheck (t ) },
404+ Steps : []resource.TestStep {
405+ {
406+ ProtoV6ProviderFactories : acctest .Providers ,
407+ SkipFunc : versionutils .CheckIfVersionIsUnsupported (minDashboardAPISupport ),
408+ ConfigDirectory : acctest .NamedTestCaseDirectory ("basic" ),
409+ ConfigVariables : config.Variables {
410+ "dashboard_title" : config .StringVariable (dashboardTitle ),
411+ },
412+ Check : resource .ComposeTestCheckFunc (
413+ resource .TestCheckResourceAttrSet ("elasticstack_kibana_dashboard.test" , "id" ),
414+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "title" , dashboardTitle ),
415+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "panels.#" , "1" ),
416+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "panels.0.type" , "lens" ),
417+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "panels.0.grid.h" , "15" ),
418+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "panels.0.grid.w" , "24" ),
419+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "panels.0.grid.x" , "0" ),
420+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "panels.0.grid.y" , "0" ),
421+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "panels.0.gauge_chart_config.title" , "Sample Gauge Chart" ),
422+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "panels.0.gauge_chart_config.description" , "Test gauge chart visualization" ),
423+ // Check dataset
424+ resource .TestCheckResourceAttrSet ("elasticstack_kibana_dashboard.test" , "panels.0.gauge_chart_config.dataset" ),
425+ // Check metric
426+ resource .TestCheckResourceAttrSet ("elasticstack_kibana_dashboard.test" , "panels.0.gauge_chart_config.metric" ),
427+ // Check shape
428+ resource .TestCheckResourceAttrSet ("elasticstack_kibana_dashboard.test" , "panels.0.gauge_chart_config.shape" ),
429+ // Check query
430+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "panels.0.gauge_chart_config.query.language" , "kuery" ),
431+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "panels.0.gauge_chart_config.query.query" , "" ),
432+ // Check sampling and filters
433+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "panels.0.gauge_chart_config.sampling" , "1" ),
434+ resource .TestCheckResourceAttr ("elasticstack_kibana_dashboard.test" , "panels.0.gauge_chart_config.ignore_global_filters" , "false" ),
435+ ),
436+ },
437+ },
438+ })
439+ }
0 commit comments