@@ -2029,6 +2029,40 @@ func TestWorkspacesUnlock(t *testing.T) {
2029
2029
assert .Equal (t , ErrWorkspaceLockedByRun , err )
2030
2030
})
2031
2031
2032
+ t .Run ("when a workspace is locked by a team" , func (t * testing.T ) {
2033
+ wTest2 , wTest2Cleanup := createWorkspace (t , client , orgTest )
2034
+ t .Cleanup (wTest2Cleanup )
2035
+
2036
+ // Create a new team to lock the workspace
2037
+ tmTest , tmTestCleanup := createTeam (t , client , orgTest )
2038
+ defer tmTestCleanup ()
2039
+ ta , err := client .TeamAccess .Add (ctx , TeamAccessAddOptions {
2040
+ Access : Access (AccessAdmin ),
2041
+ Team : tmTest ,
2042
+ Workspace : wTest2 ,
2043
+ })
2044
+ defer func () {
2045
+ err := client .TeamAccess .Remove (ctx , ta .ID )
2046
+ if err != nil {
2047
+ t .Logf ("error removing team access (%s): %s" , ta .ID , err )
2048
+ }
2049
+ }()
2050
+ tt , ttTestCleanup := createTeamToken (t , client , tmTest )
2051
+ defer ttTestCleanup ()
2052
+
2053
+ // Create a new client with the team token
2054
+ teamClient := testClient (t )
2055
+ teamClient .token = tt .Token
2056
+
2057
+ // Lock the workspace with the team client
2058
+ _ , err = teamClient .Workspaces .Lock (ctx , wTest2 .ID , WorkspaceLockOptions {})
2059
+ assert .Nil (t , err )
2060
+
2061
+ // Attempt to unlock the workspace with the original client
2062
+ _ , err = client .Workspaces .Unlock (ctx , wTest2 .ID )
2063
+ assert .Equal (t , ErrWorkspaceLockedByTeam , err )
2064
+ })
2065
+
2032
2066
t .Run ("without a valid workspace ID" , func (t * testing.T ) {
2033
2067
w , err := client .Workspaces .Unlock (ctx , badIdentifier )
2034
2068
assert .Nil (t , w )
0 commit comments