Skip to content

Commit

Permalink
test: retry workspace read resource count test
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonc committed Jul 6, 2022
1 parent d74e169 commit 507f167
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions workspace_integration_test.go
Expand Up @@ -11,6 +11,7 @@ import (
"io/ioutil"
"sort"
"strings"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -472,11 +473,33 @@ func TestWorkspacesReadWithHistory(t *testing.T) {
_, rCleanup := createAppliedRun(t, client, wTest)
defer rCleanup()

w, err := client.Workspaces.Read(context.Background(), orgTest.Name, wTest.Name)
require.NoError(t, err)
t.Helper()
wg := &sync.WaitGroup{}
wg.Add(1)

go func() {
_, err := retry(func() (interface{}, error) {
w, err := client.Workspaces.Read(context.Background(), orgTest.Name, wTest.Name)
require.NoError(t, err)

if w.RunsCount != 1 {
return nil, fmt.Errorf("expected %d runs but found %d", 1, w.RunsCount)
}

if w.ResourceCount != 1 {
return nil, fmt.Errorf("expected %d resources but found %d", 1, w.ResourceCount)
}

return w, nil
})
if err != nil {
t.Error(err)
}

wg.Done()
}()

assert.Equal(t, 1, w.RunsCount)
assert.Equal(t, 1, w.ResourceCount)
wg.Wait()
}

func TestWorkspacesReadReadme(t *testing.T) {
Expand Down

0 comments on commit 507f167

Please sign in to comment.