Skip to content

Commit

Permalink
test: TestConfigurationVersionsReadWithOptions should retry
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonc committed Jul 6, 2022
1 parent 9008efb commit fd0b70e
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions configuration_version_integration_test.go
Expand Up @@ -7,10 +7,12 @@ import (
"bytes"
"context"
"encoding/json"
"github.com/hashicorp/go-slug"
"errors"
"testing"
"time"

"github.com/hashicorp/go-slug"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -155,22 +157,25 @@ func TestConfigurationVersionsReadWithOptions(t *testing.T) {
wTest, wTestCleanup := createWorkspaceWithVCS(t, client, orgTest, WorkspaceCreateOptions{QueueAllRuns: Bool(true)})
defer wTestCleanup()

// Hack: Wait for TFC to ingress the configuration and queue a run
time.Sleep(3 * time.Second)
w, err := retry(func() (interface{}, error) {
w, err := client.Workspaces.ReadByIDWithOptions(ctx, wTest.ID, &WorkspaceReadOptions{
Include: []WSIncludeOpt{WSCurrentRunConfigVer},
})

w, err := client.Workspaces.ReadByIDWithOptions(ctx, wTest.ID, &WorkspaceReadOptions{
Include: []WSIncludeOpt{WSCurrentRunConfigVer},
})
if err != nil {
return nil, err
}

if err != nil {
require.NoError(t, err)
}
if w.CurrentRun == nil {
return nil, errors.New("A run was expected to be found on this workspace as a test pre-condition")
}

if w.CurrentRun == nil {
t.Fatal("A run was expected to be found on this workspace as a test pre-condition")
}
return w, nil
})

require.NoError(t, err)

cv := w.CurrentRun.ConfigurationVersion
cv := w.(*Workspace).CurrentRun.ConfigurationVersion

t.Run("when the configuration version exists", func(t *testing.T) {
options := &ConfigurationVersionReadOptions{
Expand Down

0 comments on commit fd0b70e

Please sign in to comment.