From 507f1671029e9f7a5174b7cd4c43101d59f53158 Mon Sep 17 00:00:00 2001 From: Brandon Croft Date: Wed, 6 Jul 2022 10:47:56 -0600 Subject: [PATCH] test: retry workspace read resource count test --- workspace_integration_test.go | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/workspace_integration_test.go b/workspace_integration_test.go index 0a9dbf476..01f8a3c5e 100644 --- a/workspace_integration_test.go +++ b/workspace_integration_test.go @@ -11,6 +11,7 @@ import ( "io/ioutil" "sort" "strings" + "sync" "testing" "time" @@ -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) {