@@ -24,11 +24,10 @@ func TestAccSumologicDashboard_basic(t *testing.T) {
2424 testNameSuffix := acctest .RandString (16 )
2525 title := "terraform_test_dashboard_" + testNameSuffix
2626
27- var dashboard Dashboard
2827 resource .Test (t , resource.TestCase {
2928 PreCheck : func () { testAccPreCheck (t ) },
3029 Providers : testAccProviders ,
31- CheckDestroy : testAccCheckDashboardDestroy (dashboard ),
30+ CheckDestroy : testAccCheckDashboardDestroy (),
3231 Steps : []resource.TestStep {
3332 {
3433 Config : dashboardImportConfig (title ),
@@ -81,7 +80,7 @@ func TestAccSumologicDashboard_create(t *testing.T) {
8180 resource .Test (t , resource.TestCase {
8281 PreCheck : func () { testAccPreCheck (t ) },
8382 Providers : testAccProviders ,
84- CheckDestroy : testAccCheckDashboardDestroy (dashboard ),
83+ CheckDestroy : testAccCheckDashboardDestroy (),
8584 Steps : []resource.TestStep {
8685 {
8786 Config : dashboardCreateConfig (title , description , theme , refreshInterval ,
@@ -211,7 +210,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
211210 resource .Test (t , resource.TestCase {
212211 PreCheck : func () { testAccPreCheck (t ) },
213212 Providers : testAccProviders ,
214- CheckDestroy : testAccCheckDashboardDestroy (dashboard ),
213+ CheckDestroy : testAccCheckDashboardDestroy (),
215214 Steps : []resource.TestStep {
216215 {
217216 Config : dashboardCreateConfig (title , description , theme , refreshInterval ,
@@ -301,12 +300,22 @@ func TestAccSumologicDashboard_update(t *testing.T) {
301300 })
302301}
303302
304- func testAccCheckDashboardDestroy (dashboard Dashboard ) resource.TestCheckFunc {
303+ func testAccCheckDashboardDestroy () resource.TestCheckFunc {
305304 return func (s * terraform.State ) error {
306305 client := testAccProvider .Meta ().(* Client )
307- _ , err := client .GetDashboard (dashboard .ID )
308- if err == nil {
309- return fmt .Errorf ("Dashboard (id=%s) still exists" , dashboard .ID )
306+ for _ , r := range s .RootModule ().Resources {
307+ if r .Type != "sumologic_dashboard" {
308+ continue
309+ }
310+
311+ id := r .Primary .ID
312+ dashboard , err := client .GetDashboard (id )
313+ if err != nil {
314+ return fmt .Errorf ("Encountered an error: " + err .Error ())
315+ }
316+ if dashboard != nil {
317+ return fmt .Errorf ("Dashboard (id=%s) still exists" , id )
318+ }
310319 }
311320 return nil
312321 }
0 commit comments