Skip to content

Commit

Permalink
Test case for unlocking a workspace when it has been locked by a team
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmelin committed Sep 12, 2024
1 parent b3c04ec commit 8e09912
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions workspace_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,40 @@ func TestWorkspacesUnlock(t *testing.T) {
assert.Equal(t, ErrWorkspaceLockedByRun, err)
})

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

// Create a new team to lock the workspace
tmTest, tmTestCleanup := createTeam(t, client, orgTest)
defer tmTestCleanup()
ta, err := client.TeamAccess.Add(ctx, TeamAccessAddOptions{

Check failure on line 2039 in workspace_integration_test.go

View workflow job for this annotation

GitHub Actions / Lint

ineffectual assignment to err (ineffassign)
Access: Access(AccessAdmin),
Team: tmTest,
Workspace: wTest2,
})
defer func() {
err := client.TeamAccess.Remove(ctx, ta.ID)
if err != nil {
t.Logf("error removing team access (%s): %s", ta.ID, err)
}
}()
tt, ttTestCleanup := createTeamToken(t, client, tmTest)
defer ttTestCleanup()

// Create a new client with the team token
teamClient := testClient(t)
teamClient.token = tt.Token

// Lock the workspace with the team client
_, err = teamClient.Workspaces.Lock(ctx, wTest2.ID, WorkspaceLockOptions{})
assert.Nil(t, err)

// Attempt to unlock the workspace with the original client
_, err = client.Workspaces.Unlock(ctx, wTest2.ID)
assert.Equal(t, ErrWorkspaceLockedByTeam, err)
})

t.Run("without a valid workspace ID", func(t *testing.T) {
w, err := client.Workspaces.Unlock(ctx, badIdentifier)
assert.Nil(t, w)
Expand Down

0 comments on commit 8e09912

Please sign in to comment.