Skip to content

Commit eba5b73

Browse files
Fix flaky report test (#1305)
Sometimes, there are conflicts with the static "report" dashboard name
1 parent 66ef898 commit eba5b73

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

internal/resources/grafana/resource_report_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ func TestAccResourceReport_Multiple_Dashboards(t *testing.T) {
1616
testutils.CheckEnterpriseTestsEnabled(t)
1717

1818
var report models.Report
19+
var randomUID = acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
20+
var randomUID2 = acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
1921

2022
resource.ParallelTest(t, resource.TestCase{
2123
ProviderFactories: testutils.ProviderFactories,
2224
CheckDestroy: reportCheckExists.destroyed(&report, nil),
2325
Steps: []resource.TestStep{
2426
{
25-
Config: testutils.TestAccExample(t, "resources/grafana_report/multiple-dashboards.tf"),
27+
Config: testutils.TestAccExampleWithReplace(t, "resources/grafana_report/multiple-dashboards.tf", map[string]string{
28+
`"uid": "report"`: fmt.Sprintf(`"uid": "%s"`, randomUID),
29+
`"uid": "report2"`: fmt.Sprintf(`"uid": "%s"`, randomUID2),
30+
}),
2631
Check: resource.ComposeTestCheckFunc(
2732
reportCheckExists.exists("grafana_report.test", &report),
2833
resource.TestCheckResourceAttrSet("grafana_report.test", "id"),
@@ -42,12 +47,12 @@ func TestAccResourceReport_Multiple_Dashboards(t *testing.T) {
4247
resource.TestCheckResourceAttr("grafana_report.test", "include_table_csv", "false"),
4348
resource.TestCheckNoResourceAttr("grafana_report.test", "time_range.0.from"),
4449
resource.TestCheckNoResourceAttr("grafana_report.test", "time_range.0.to"),
45-
resource.TestCheckResourceAttr("grafana_report.test", "dashboards.0.uid", "report"),
50+
resource.TestCheckResourceAttr("grafana_report.test", "dashboards.0.uid", randomUID),
4651
resource.TestCheckResourceAttr("grafana_report.test", "dashboards.0.time_range.0.from", "now-1h"),
4752
resource.TestCheckResourceAttr("grafana_report.test", "dashboards.0.time_range.0.to", "now"),
4853
resource.TestCheckResourceAttr("grafana_report.test", "dashboards.1.time_range.0.from", ""),
4954
resource.TestCheckResourceAttr("grafana_report.test", "dashboards.1.time_range.0.to", ""),
50-
resource.TestCheckResourceAttr("grafana_report.test", "dashboards.1.uid", "report2"),
55+
resource.TestCheckResourceAttr("grafana_report.test", "dashboards.1.uid", randomUID2),
5156
),
5257
},
5358
},

0 commit comments

Comments
 (0)