@@ -68,13 +68,45 @@ func TestLogin(t *testing.T) {
68
68
<- doneChan
69
69
})
70
70
71
- t .Run ("InitialUserFlags " , func (t * testing.T ) {
71
+ t .Run ("InitialUserTTYFlag " , func (t * testing.T ) {
72
72
t .Parallel ()
73
73
client := coderdtest .New (t , nil )
74
74
// The --force-tty flag is required on Windows, because the `isatty` library does not
75
75
// accurately detect Windows ptys when they are not attached to a process:
76
76
// https://github.com/mattn/go-isatty/issues/59
77
77
doneChan := make (chan struct {})
78
+ root , _ := clitest .New (t , "--url" , client .URL .String (), "login" , "--force-tty" )
79
+ pty := ptytest .New (t )
80
+ root .SetIn (pty .Input ())
81
+ root .SetOut (pty .Output ())
82
+ go func () {
83
+ defer close (doneChan )
84
+ err := root .Execute ()
85
+ assert .NoError (t , err )
86
+ }()
87
+
88
+ matches := []string {
89
+ "first user?" , "yes" ,
90
+ "username" , "testuser" ,
91
+ "email" , "user@coder.com" ,
92
+ "password" , "password" ,
93
+ "password" , "password" , // Confirm.
94
+ "trial" , "yes" ,
95
+ }
96
+ for i := 0 ; i < len (matches ); i += 2 {
97
+ match := matches [i ]
98
+ value := matches [i + 1 ]
99
+ pty .ExpectMatch (match )
100
+ pty .WriteLine (value )
101
+ }
102
+ pty .ExpectMatch ("Welcome to Coder" )
103
+ <- doneChan
104
+ })
105
+
106
+ t .Run ("InitialUserFlags" , func (t * testing.T ) {
107
+ t .Parallel ()
108
+ client := coderdtest .New (t , nil )
109
+ doneChan := make (chan struct {})
78
110
root , _ := clitest .New (t , "login" , client .URL .String (), "--first-user-username" , "testuser" , "--first-user-email" , "user@coder.com" , "--first-user-password" , "password" , "--first-user-trial" )
79
111
pty := ptytest .New (t )
80
112
root .SetIn (pty .Input ())
0 commit comments