File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ package cli_test
2
+
3
+ import (
4
+ "bytes"
5
+ "testing"
6
+
7
+ "github.com/stretchr/testify/require"
8
+
9
+ "github.com/coder/coder/v2/cli/clitest"
10
+ "github.com/coder/coder/v2/coderd/coderdtest"
11
+ )
12
+
13
+ func TestWhoami (t * testing.T ) {
14
+ t .Parallel ()
15
+
16
+ t .Run ("InitialUserNoTTY" , func (t * testing.T ) {
17
+ t .Parallel ()
18
+ client := coderdtest .New (t , nil )
19
+ root , _ := clitest .New (t , "login" , client .URL .String ())
20
+ err := root .Run ()
21
+ require .Error (t , err )
22
+ })
23
+
24
+ t .Run ("OK" , func (t * testing.T ) {
25
+ t .Parallel ()
26
+ client := coderdtest .New (t , nil )
27
+ _ = coderdtest .CreateFirstUser (t , client )
28
+ inv , root := clitest .New (t , "whoami" )
29
+ clitest .SetupConfig (t , client , root )
30
+ buf := new (bytes.Buffer )
31
+ inv .Stdout = buf
32
+ err := inv .Run ()
33
+ require .NoError (t , err )
34
+ whoami := buf .String ()
35
+ require .NotEmpty (t , whoami )
36
+ })
37
+ }
You can’t perform that action at this time.
0 commit comments