Skip to content

Commit

Permalink
Merge pull request #427 from hashicorp/brandonc/TestWorkspacesUnlock
Browse files Browse the repository at this point in the history
flake TestWorkspacesUnlock
  • Loading branch information
brandonc committed Jun 10, 2022
2 parents 7f5d83c + 45ecd02 commit e2887f5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions workspace_integration_test.go
Expand Up @@ -939,22 +939,13 @@ func TestWorkspacesUnlock(t *testing.T) {
wTest, wTestCleanup := createWorkspace(t, client, orgTest)
defer wTestCleanup()

wTest2, wTest2Cleanup := createWorkspace(t, client, orgTest)
defer wTest2Cleanup()

w, err := client.Workspaces.Lock(ctx, wTest.ID, WorkspaceLockOptions{})
if err != nil {
orgTestCleanup()
}
require.NoError(t, err)
require.True(t, w.Locked)

_, rTestCleanup := createRun(t, client, wTest2)
defer rTestCleanup()

// Wait for wTest2 to be locked by a run
waitForRunLock(t, client, wTest2.ID)

t.Run("with valid options", func(t *testing.T) {
w, err := client.Workspaces.Unlock(ctx, wTest.ID)
require.NoError(t, err)
Expand All @@ -967,6 +958,15 @@ func TestWorkspacesUnlock(t *testing.T) {
})

t.Run("when a workspace is locked by a run", func(t *testing.T) {
wTest2, wTest2Cleanup := createWorkspace(t, client, orgTest)
defer wTest2Cleanup()

_, rTestCleanup := createRun(t, client, wTest2)
defer rTestCleanup()

// Wait for wTest2 to be locked by a run
waitForRunLock(t, client, wTest2.ID)

_, err = client.Workspaces.Unlock(ctx, wTest2.ID)
assert.Equal(t, ErrWorkspaceLockedByRun, err)
})
Expand Down

0 comments on commit e2887f5

Please sign in to comment.