Skip to content

Commit 441f471

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 441f471

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mmv1/third_party/terraform/acctest/resource_test_utils.go

+6-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,11 @@ 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+
vcrMode := os.Getenv("VCR_MODE")
96+
if vcrMode == "REPLAYING" {
97+
time.Sleep(time.Duration(t) * time.Second)
98+
}
9499
return nil
95100
}
96101
}

0 commit comments

Comments
 (0)