Skip to content

Commit 1656389

Browse files
committed
Skip sleep in VCR replaying mode
In `SleepInSecondsForTest()`, skip the sleep when `VCR_MODE` is `REPLAYING`. This makes the assumption that the sleep is always related to a condition that's already mitigated by the fact that we're using prerecorded fixtures, but it could be extended later to override this behavior if necessary. Fixes hashicorp/terraform-provider-google#20916
1 parent cba2ae3 commit 1656389

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mmv1/third_party/terraform/acctest/resource_test_utils.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"os"
78
"slices"
89
"testing"
910
"time"
@@ -90,7 +91,10 @@ func SkipIfVcr(t *testing.T) {
9091

9192
func SleepInSecondsForTest(t int) resource.TestCheckFunc {
9293
return func(s *terraform.State) error {
93-
time.Sleep(time.Duration(t) * time.Second)
94+
// Assume we never want to sleep when we're in replaying mode.
95+
if os.Getenv("VCR_MODE") != "REPLAYING" {
96+
time.Sleep(time.Duration(t) * time.Second)
97+
}
9498
return nil
9599
}
96100
}

0 commit comments

Comments
 (0)