1
1
package cli_test
2
2
3
3
import (
4
- "bytes"
5
4
"context"
6
5
"path/filepath"
7
6
"testing"
@@ -12,7 +11,6 @@ import (
12
11
13
12
"github.com/coder/coder/v2/cli/clitest"
14
13
"github.com/coder/coder/v2/coderd/coderdtest"
15
- "github.com/coder/coder/v2/codersdk"
16
14
"github.com/coder/coder/v2/pty/ptytest"
17
15
"github.com/coder/coder/v2/testutil"
18
16
)
@@ -118,59 +116,6 @@ func TestScaleTestWorkspaceTraffic_Template(t *testing.T) {
118
116
require .ErrorContains (t , err , "could not find template \" doesnotexist\" in any organization" )
119
117
}
120
118
121
- // This test validates that the scaletest CLI filters out workspaces not owned
122
- // when disable owner workspace access is set.
123
- // nolint:paralleltest // DisableOwnerWorkspaceExec is not safe for parallel tests.
124
- func TestScaleTestWorkspaceTraffic_UseHostLogin (t * testing.T ) {
125
- ctx , cancelFunc := context .WithTimeout (context .Background (), testutil .WaitMedium )
126
- defer cancelFunc ()
127
-
128
- log := slogtest .Make (t , & slogtest.Options {IgnoreErrors : true })
129
- client := coderdtest .New (t , & coderdtest.Options {
130
- Logger : & log ,
131
- IncludeProvisionerDaemon : true ,
132
- DeploymentValues : coderdtest .DeploymentValues (t , func (dv * codersdk.DeploymentValues ) {
133
- dv .DisableOwnerWorkspaceExec = true
134
- }),
135
- })
136
- owner := coderdtest .CreateFirstUser (t , client )
137
- tv := coderdtest .CreateTemplateVersion (t , client , owner .OrganizationID , nil )
138
- _ = coderdtest .AwaitTemplateVersionJobCompleted (t , client , tv .ID )
139
- tpl := coderdtest .CreateTemplate (t , client , owner .OrganizationID , tv .ID )
140
- // Create a workspace owned by a different user
141
- memberClient , _ := coderdtest .CreateAnotherUser (t , client , owner .OrganizationID )
142
- _ = coderdtest .CreateWorkspace (t , memberClient , tpl .ID , func (cwr * codersdk.CreateWorkspaceRequest ) {
143
- cwr .Name = "scaletest-workspace"
144
- })
145
-
146
- // Test without --use-host-login first.
147
- inv , root := clitest .New (t , "exp" , "scaletest" , "workspace-traffic" ,
148
- "--template" , tpl .Name ,
149
- )
150
- // nolint:gocritic // We are intentionally testing this as the owner.
151
- clitest .SetupConfig (t , client , root )
152
- var stdoutBuf bytes.Buffer
153
- inv .Stdout = & stdoutBuf
154
-
155
- err := inv .WithContext (ctx ).Run ()
156
- require .ErrorContains (t , err , "no scaletest workspaces exist" )
157
- require .Contains (t , stdoutBuf .String (), `1 workspace(s) were skipped` )
158
-
159
- // Test once again with --use-host-login.
160
- inv , root = clitest .New (t , "exp" , "scaletest" , "workspace-traffic" ,
161
- "--template" , tpl .Name ,
162
- "--use-host-login" ,
163
- )
164
- // nolint:gocritic // We are intentionally testing this as the owner.
165
- clitest .SetupConfig (t , client , root )
166
- stdoutBuf .Reset ()
167
- inv .Stdout = & stdoutBuf
168
-
169
- err = inv .WithContext (ctx ).Run ()
170
- require .ErrorContains (t , err , "no scaletest workspaces exist" )
171
- require .NotContains (t , stdoutBuf .String (), `1 workspace(s) were skipped` )
172
- }
173
-
174
119
// This test just validates that the CLI command accepts its known arguments.
175
120
func TestScaleTestWorkspaceTraffic_TargetWorkspaces (t * testing.T ) {
176
121
t .Parallel ()
0 commit comments