Skip to content

Commit 56c20c9

Browse files
committed
tests: increase test resiliency
1 parent 17d851b commit 56c20c9

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

helper_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3140,18 +3140,22 @@ func retryTimesIf[T any](maxRetries, secondsBetween int, f retryableFn, c func(T
31403140
}
31413141
}
31423142

3143-
func retryPatiently(f retryableFn) (interface{}, error) { //nolint
3143+
func retryPatiently(f retryableFn) (interface{}, error) {
31443144
return retryTimes(39, 3, f) // 40 attempts over 120 seconds
31453145
}
31463146

3147-
func retryIf[T any](f retryableFn, c func(T) bool) (T, error) { //nolint
3148-
return retryTimesIf[T](9, 3, f, c) // 10 attempts over 30 seconds
3149-
}
3150-
31513147
func retry(f retryableFn) (interface{}, error) { //nolint
31523148
return retryTimes(9, 3, f) // 10 attempts over 30 seconds
31533149
}
31543150

3151+
func retryPatientlyIf[T any](f retryableFn, c func(T) bool) (T, error) {
3152+
return retryTimesIf[T](39, 3, f, c) // 40 attempts over 120 seconds
3153+
}
3154+
3155+
func retryIf[T any](f retryableFn, c func(T) bool) (T, error) {
3156+
return retryTimesIf[T](9, 3, f, c) // 10 attempts over 30 seconds
3157+
}
3158+
31553159
func genSha(t *testing.T) string {
31563160
t.Helper()
31573161
h := hmac.New(sha256.New, []byte("secret"))

workspace_integration_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2320,6 +2320,7 @@ func TestWorkspacesSafeDelete(t *testing.T) {
23202320

23212321
func TestWorkspacesSafeDeleteByID(t *testing.T) {
23222322
t.Parallel()
2323+
23232324
client := testClient(t)
23242325
ctx := context.Background()
23252326

@@ -2360,7 +2361,7 @@ func TestWorkspacesSafeDeleteByID(t *testing.T) {
23602361
_, svTestCleanup := createStateVersion(t, client, 0, wTest)
23612362
t.Cleanup(svTestCleanup)
23622363

2363-
_, err := retry(func() (interface{}, error) {
2364+
_, err := retryPatiently(func() (interface{}, error) {
23642365
err := client.Workspaces.SafeDeleteByID(ctx, wTest.ID)
23652366
if errors.Is(err, ErrWorkspaceStillProcessing) {
23662367
return nil, err

workspace_resources_integration_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestWorkspaceResourcesList(t *testing.T) {
3333
// Retry while waiting for workspace resources to be populated.
3434
// This can take some time after the state version is created, so we
3535
// retry the list call until we get non-empty results.
36-
rs, err := retryIf(
36+
rs, err := retryPatientlyIf(
3737
func() (any, error) {
3838
return client.WorkspaceResources.List(ctx, wTest.ID, nil)
3939
},
@@ -43,6 +43,8 @@ func TestWorkspaceResourcesList(t *testing.T) {
4343
)
4444

4545
require.NoError(t, err)
46+
require.NotNil(t, rs)
47+
require.NotNil(t, rs.Items)
4648
require.NotEmpty(t, rs.Items)
4749
assert.Equal(t, 1, len(rs.Items))
4850
assert.Equal(t, 1, rs.CurrentPage)

0 commit comments

Comments
 (0)