@@ -11,6 +11,7 @@ import (
11
11
12
12
"github.com/coder/coder/v2/cli/clitest"
13
13
"github.com/coder/coder/v2/coderd/coderdtest"
14
+ "github.com/coder/coder/v2/coderd/rbac"
14
15
"github.com/coder/coder/v2/codersdk"
15
16
"github.com/coder/coder/v2/pty/ptytest"
16
17
)
@@ -20,9 +21,10 @@ func TestUserList(t *testing.T) {
20
21
t .Run ("Table" , func (t * testing.T ) {
21
22
t .Parallel ()
22
23
client := coderdtest .New (t , nil )
23
- coderdtest .CreateFirstUser (t , client )
24
+ admin := coderdtest .CreateFirstUser (t , client )
25
+ userAdmin , _ := coderdtest .CreateAnotherUser (t , client , admin .OrganizationID , rbac .RoleUserAdmin ())
24
26
inv , root := clitest .New (t , "users" , "list" )
25
- clitest .SetupConfig (t , client , root )
27
+ clitest .SetupConfig (t , userAdmin , root )
26
28
pty := ptytest .New (t ).Attach (inv )
27
29
errC := make (chan error )
28
30
go func () {
@@ -35,9 +37,10 @@ func TestUserList(t *testing.T) {
35
37
t .Parallel ()
36
38
37
39
client := coderdtest .New (t , nil )
38
- coderdtest .CreateFirstUser (t , client )
40
+ admin := coderdtest .CreateFirstUser (t , client )
41
+ userAdmin , _ := coderdtest .CreateAnotherUser (t , client , admin .OrganizationID , rbac .RoleUserAdmin ())
39
42
inv , root := clitest .New (t , "users" , "list" , "-o" , "json" )
40
- clitest .SetupConfig (t , client , root )
43
+ clitest .SetupConfig (t , userAdmin , root )
41
44
doneChan := make (chan struct {})
42
45
43
46
buf := bytes .NewBuffer (nil )
@@ -53,7 +56,7 @@ func TestUserList(t *testing.T) {
53
56
var users []codersdk.User
54
57
err := json .Unmarshal (buf .Bytes (), & users )
55
58
require .NoError (t , err , "unmarshal JSON output" )
56
- require .Len (t , users , 1 )
59
+ require .Len (t , users , 2 )
57
60
require .Contains (t , users [0 ].Email , "coder.com" )
58
61
})
59
62
t .Run ("NoURLFileErrorHasHelperText" , func (t * testing.T ) {
@@ -85,9 +88,10 @@ func TestUserShow(t *testing.T) {
85
88
t .Parallel ()
86
89
client := coderdtest .New (t , nil )
87
90
admin := coderdtest .CreateFirstUser (t , client )
91
+ userAdmin , _ := coderdtest .CreateAnotherUser (t , client , admin .OrganizationID , rbac .RoleUserAdmin ())
88
92
_ , otherUser := coderdtest .CreateAnotherUser (t , client , admin .OrganizationID )
89
93
inv , root := clitest .New (t , "users" , "show" , otherUser .Username )
90
- clitest .SetupConfig (t , client , root )
94
+ clitest .SetupConfig (t , userAdmin , root )
91
95
doneChan := make (chan struct {})
92
96
pty := ptytest .New (t ).Attach (inv )
93
97
go func () {
@@ -105,11 +109,12 @@ func TestUserShow(t *testing.T) {
105
109
ctx := context .Background ()
106
110
client := coderdtest .New (t , nil )
107
111
admin := coderdtest .CreateFirstUser (t , client )
112
+ userAdmin , _ := coderdtest .CreateAnotherUser (t , client , admin .OrganizationID , rbac .RoleUserAdmin ())
108
113
other , _ := coderdtest .CreateAnotherUser (t , client , admin .OrganizationID )
109
114
otherUser , err := other .User (ctx , codersdk .Me )
110
115
require .NoError (t , err , "fetch other user" )
111
116
inv , root := clitest .New (t , "users" , "show" , otherUser .Username , "-o" , "json" )
112
- clitest .SetupConfig (t , client , root )
117
+ clitest .SetupConfig (t , userAdmin , root )
113
118
doneChan := make (chan struct {})
114
119
115
120
buf := bytes .NewBuffer (nil )
0 commit comments