From 138802ff4ecf7f2374c472b3e13bd6105ab8dc37 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 | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/workspace_integration_test.go b/workspace_integration_test.go index 0a9dbf476..ca0e9e006 100644 --- a/workspace_integration_test.go +++ b/workspace_integration_test.go @@ -472,11 +472,24 @@ 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) + _, 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 + }) - assert.Equal(t, 1, w.RunsCount) - assert.Equal(t, 1, w.ResourceCount) + if err != nil { + t.Error(err) + } } func TestWorkspacesReadReadme(t *testing.T) {