Skip to content

Commit 12867f6

Browse files
committed
Retry check destroy result workspace_run
1 parent 3fc4603 commit 12867f6

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

internal/provider/resource_tfe_workspace_run_test.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,18 +258,22 @@ func testAccCheckTFEWorkspaceRunDestroy(workspaceID string, expectedDestroyCount
258258
return func(s *terraform.State) error {
259259
config := testAccProvider.Meta().(ConfiguredClient)
260260

261-
runList, err := config.Client.Runs.List(ctx, workspaceID, &tfe.RunListOptions{
262-
Operation: "destroy",
261+
_, err := retryFn(10, 1, func() (interface{}, error) {
262+
runList, err := config.Client.Runs.List(ctx, workspaceID, &tfe.RunListOptions{
263+
Operation: "destroy",
264+
})
265+
if err != nil {
266+
return nil, fmt.Errorf("Unable to find destroy run, %w", err)
267+
}
268+
269+
if len(runList.Items) != expectedDestroyCount {
270+
return nil, fmt.Errorf("Expected %d destroy runs but found %d", expectedDestroyCount, len(runList.Items))
271+
}
272+
273+
return nil, nil
263274
})
264-
if err != nil {
265-
return fmt.Errorf("Unable to find destroy run, %w", err)
266-
}
267275

268-
if len(runList.Items) != expectedDestroyCount {
269-
return fmt.Errorf("Expected %d destroy runs but found %d", expectedDestroyCount, len(runList.Items))
270-
}
271-
272-
return nil
276+
return err
273277
}
274278
}
275279

0 commit comments

Comments
 (0)