Skip to content

Commit 5828bc7

Browse files
committed
replace hardcoded timeouts with DestroyWaitTimeout
1 parent d1c8796 commit 5828bc7

File tree

30 files changed

+80
-46
lines changed

30 files changed

+80
-46
lines changed

internal/services/account/project_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/account"
1616
)
1717

18+
var DestroyWaitTimeout = 3 * time.Minute
19+
1820
func TestAccProject_Basic(t *testing.T) {
1921
tt := acctest.NewTestTools(t)
2022
defer tt.Cleanup()
@@ -108,7 +110,7 @@ func isProjectDestroyed(tt *acctest.TestTools) resource.TestCheckFunc {
108110
ctx := context.Background()
109111
api := account.NewProjectAPI(tt.Meta)
110112

111-
return retry.RetryContext(ctx, 3*time.Minute, func() *retry.RetryError {
113+
return retry.RetryContext(ctx, DestroyWaitTimeout, func() *retry.RetryError {
112114
for _, rs := range state.RootModule().Resources {
113115
if rs.Type != "scaleway_account_project" {
114116
continue

internal/services/baremetal/testfuncs/checks.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ import (
1414
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/baremetal"
1515
)
1616

17+
var DestroyWaitTimeout = 3 * time.Minute
18+
1719
func CheckServerDestroy(tt *acctest.TestTools) resource.TestCheckFunc {
1820
return func(state *terraform.State) error {
1921
ctx := context.Background()
2022

21-
return retry.RetryContext(ctx, 3*time.Minute, func() *retry.RetryError {
23+
return retry.RetryContext(ctx, DestroyWaitTimeout, func() *retry.RetryError {
2224
for _, rs := range state.RootModule().Resources {
2325
if rs.Type != "scaleway_baremetal_server" {
2426
continue

internal/services/cockpit/source_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/cockpit"
1616
)
1717

18+
var DestroyWaitTimeout = 3 * time.Minute
19+
1820
func TestAccCockpitSource_Basic_metrics(t *testing.T) {
1921
tt := acctest.NewTestTools(t)
2022
defer tt.Cleanup()
@@ -236,7 +238,7 @@ func isSourceDestroyed(tt *acctest.TestTools) resource.TestCheckFunc {
236238
return func(state *terraform.State) error {
237239
ctx := context.Background()
238240

239-
return retry.RetryContext(ctx, 3*time.Minute, func() *retry.RetryError {
241+
return retry.RetryContext(ctx, DestroyWaitTimeout, func() *retry.RetryError {
240242
for _, rs := range state.RootModule().Resources {
241243
if rs.Type != "scaleway_cockpit_source" {
242244
continue

internal/services/flexibleip/ip_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222

2323
const SSHKeyFlexibleIP = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM7HUxRyQtB2rnlhQUcbDGCZcTJg7OvoznOiyC9W6IxH [email protected]"
2424

25+
var DestroyWaitTimeout = 3 * time.Minute
26+
2527
func TestAccFlexibleIP_Basic(t *testing.T) {
2628
tt := acctest.NewTestTools(t)
2729
defer tt.Cleanup()
@@ -329,7 +331,7 @@ func testAccCheckFlexibleIPDestroy(tt *acctest.TestTools) resource.TestCheckFunc
329331
return func(state *terraform.State) error {
330332
ctx := context.Background()
331333

332-
return retry.RetryContext(ctx, 3*time.Minute, func() *retry.RetryError {
334+
return retry.RetryContext(ctx, DestroyWaitTimeout, func() *retry.RetryError {
333335
for _, rs := range state.RootModule().Resources {
334336
if rs.Type != "scaleway_flexible_ip" {
335337
continue

internal/services/iam/api_key_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
"testing"
7-
"time"
87

98
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
109
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -13,6 +12,7 @@ import (
1312
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest"
1413
"github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
1514
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/iam"
15+
iamchecks "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/iam/testfuncs"
1616
)
1717

1818
func TestAccApiKey_WithApplication(t *testing.T) {
@@ -253,7 +253,7 @@ func testAccCheckIamAPIKeyDestroy(tt *acctest.TestTools) resource.TestCheckFunc
253253
api := iam.NewAPI(tt.Meta)
254254
ctx := context.Background()
255255

256-
return retry.RetryContext(ctx, 3*time.Minute, func() *retry.RetryError {
256+
return retry.RetryContext(ctx, iamchecks.DestroyWaitTimeout, func() *retry.RetryError {
257257
for _, rs := range s.RootModule().Resources {
258258
if rs.Type != "scaleway_iam_api_key" {
259259
continue

internal/services/iam/application_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
"testing"
7-
"time"
87

98
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
109
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -13,6 +12,7 @@ import (
1312
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest"
1413
"github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
1514
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/iam"
15+
iamchecks "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/iam/testfuncs"
1616
)
1717

1818
func TestAccApplication_Basic(t *testing.T) {
@@ -115,7 +115,7 @@ func testAccCheckIamApplicationDestroy(tt *acctest.TestTools) resource.TestCheck
115115
api := iam.NewAPI(tt.Meta)
116116
ctx := context.Background()
117117

118-
return retry.RetryContext(ctx, 3*time.Minute, func() *retry.RetryError {
118+
return retry.RetryContext(ctx, iamchecks.DestroyWaitTimeout, func() *retry.RetryError {
119119
for _, rs := range s.RootModule().Resources {
120120
if rs.Type != "scaleway_iam_application" {
121121
continue

internal/services/iam/group_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
"testing"
7-
"time"
87

98
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
109
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -13,6 +12,7 @@ import (
1312
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest"
1413
"github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
1514
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/iam"
15+
iamchecks "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/iam/testfuncs"
1616
)
1717

1818
func TestAccGroup_Basic(t *testing.T) {
@@ -484,7 +484,7 @@ func testAccCheckIamGroupDestroy(tt *acctest.TestTools) resource.TestCheckFunc {
484484
api := iam.NewAPI(tt.Meta)
485485
ctx := context.Background()
486486

487-
return retry.RetryContext(ctx, 3*time.Minute, func() *retry.RetryError {
487+
return retry.RetryContext(ctx, iamchecks.DestroyWaitTimeout, func() *retry.RetryError {
488488
for _, rs := range s.RootModule().Resources {
489489
if rs.Type != "scaleway_iam_group" {
490490
continue

internal/services/iam/testfuncs/checks.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ import (
1414
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/iam"
1515
)
1616

17+
var DestroyWaitTimeout = 3 * time.Minute
18+
1719
func CheckSSHKeyDestroy(tt *acctest.TestTools) resource.TestCheckFunc {
1820
return func(state *terraform.State) error {
1921
api := iam.NewAPI(tt.Meta)
2022
ctx := context.Background()
2123

22-
return retry.RetryContext(ctx, 3*time.Minute, func() *retry.RetryError {
24+
return retry.RetryContext(ctx, DestroyWaitTimeout, func() *retry.RetryError {
2325
for _, rs := range state.RootModule().Resources {
2426
if rs.Type != "scaleway_iam_ssh_key" {
2527
continue

internal/services/inference/testfuncs/checks.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/inference"
1515
)
1616

17+
var DestroyWaitTimeout = 3 * time.Minute
18+
1719
func IsDeploymentDestroyed(tt *acctest.TestTools) resource.TestCheckFunc {
1820
return func(s *terraform.State) error {
1921
for _, rs := range s.RootModule().Resources {
@@ -48,7 +50,7 @@ func IsModelDestroyed(tt *acctest.TestTools) resource.TestCheckFunc {
4850
return func(state *terraform.State) error {
4951
ctx := context.Background()
5052

51-
return retry.RetryContext(ctx, 3*time.Minute, func() *retry.RetryError {
53+
return retry.RetryContext(ctx, DestroyWaitTimeout, func() *retry.RetryError {
5254
for _, rs := range state.RootModule().Resources {
5355
if rs.Type != "scaleway_inference_model" {
5456
continue

internal/services/instance/placement_group_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
"testing"
7-
"time"
87

98
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
109
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -174,7 +173,7 @@ func isPlacementGroupDestroyed(tt *acctest.TestTools) resource.TestCheckFunc {
174173
return func(state *terraform.State) error {
175174
ctx := context.Background()
176175

177-
return retry.RetryContext(ctx, 3*time.Minute, func() *retry.RetryError {
176+
return retry.RetryContext(ctx, instancechecks.DestroyWaitTimeout, func() *retry.RetryError {
178177
for _, rs := range state.RootModule().Resources {
179178
if rs.Type != "scaleway_instance_placement_group" {
180179
continue

0 commit comments

Comments
 (0)