Skip to content

Commit 066f517

Browse files
committed
208 problems left...
* More stdio wiring
1 parent 058ff8b commit 066f517

33 files changed

+162
-162
lines changed

cli/cliui/agent_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestAgent(t *testing.T) {
4646
},
4747
}
4848
cmd.SetOutput(ptty.Output())
49-
cmd.SetIn(ptty.Input())
49+
cmd.Stdin = ptty.Input()
5050
done := make(chan struct{})
5151
go func() {
5252
defer close(done)
@@ -93,7 +93,7 @@ func TestAgent_TimeoutWithTroubleshootingURL(t *testing.T) {
9393
}
9494
ptty := ptytest.New(t)
9595
cmd.SetOutput(ptty.Output())
96-
cmd.SetIn(ptty.Input())
96+
cmd.Stdin = ptty.Input()
9797
done := make(chan error, 1)
9898
go func() {
9999
done <- cmd.WithContext(ctx).Run()
@@ -146,7 +146,7 @@ func TestAgent_StartupTimeout(t *testing.T) {
146146

147147
ptty := ptytest.New(t)
148148
cmd.SetOutput(ptty.Output())
149-
cmd.SetIn(ptty.Input())
149+
cmd.Stdin = ptty.Input()
150150
done := make(chan error, 1)
151151
go func() {
152152
done <- cmd.WithContext(ctx).Run()
@@ -204,7 +204,7 @@ func TestAgent_StartErrorExit(t *testing.T) {
204204

205205
ptty := ptytest.New(t)
206206
cmd.SetOutput(ptty.Output())
207-
cmd.SetIn(ptty.Input())
207+
cmd.Stdin = ptty.Input()
208208
done := make(chan error, 1)
209209
go func() {
210210
done <- cmd.WithContext(ctx).Run()
@@ -259,7 +259,7 @@ func TestAgent_NoWait(t *testing.T) {
259259

260260
ptty := ptytest.New(t)
261261
cmd.SetOutput(ptty.Output())
262-
cmd.SetIn(ptty.Input())
262+
cmd.Stdin = ptty.Input()
263263
done := make(chan error, 1)
264264
go func() {
265265
done <- cmd.WithContext(ctx).Run()
@@ -328,7 +328,7 @@ func TestAgent_LoginBeforeReadyEnabled(t *testing.T) {
328328

329329
ptty := ptytest.New(t)
330330
cmd.SetOutput(ptty.Output())
331-
cmd.SetIn(ptty.Input())
331+
cmd.Stdin = ptty.Input()
332332
done := make(chan error, 1)
333333
go func() {
334334
done <- cmd.WithContext(ctx).Run()

cli/cliui/gitauth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestGitAuth(t *testing.T) {
4141
},
4242
}
4343
cmd.SetOutput(ptty.Output())
44-
cmd.SetIn(ptty.Input())
44+
cmd.Stdin = ptty.Input()
4545
done := make(chan struct{})
4646
go func() {
4747
defer close(done)

cli/cliui/prompt_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ func newPrompt(ptty *ptytest.PTY, opts cliui.PromptOptions, cmdOpt func(cmd *cob
158158
if cmdOpt != nil {
159159
cmdOpt(cmd)
160160
}
161-
cmd.SetOut(ptty.Output())
162-
cmd.SetErr(ptty.Output())
163-
cmd.SetIn(ptty.Input())
161+
cmd.Stdout = ptty.Output()
162+
cmd.Stderr = ptty.Output()
163+
cmd.Stdin = ptty.Input()
164164
return value, cmd.RunContext(context.Background())
165165
}
166166

cli/cliui/provisionerjob_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func newProvisionerJob(t *testing.T) provisionerJobTest {
147147
}
148148
ptty := ptytest.New(t)
149149
cmd.SetOutput(ptty.Output())
150-
cmd.SetIn(ptty.Input())
150+
cmd.Stdin = ptty.Input()
151151
done := make(chan struct{})
152152
go func() {
153153
defer close(done)

cli/cliui/select_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func newSelect(ptty *ptytest.PTY, opts cliui.SelectOptions) (string, error) {
4040
},
4141
}
4242
cmd.SetOutput(ptty.Output())
43-
cmd.SetIn(ptty.Input())
43+
cmd.Stdin = ptty.Input()
4444
return value, cmd.RunContext(context.Background())
4545
}
4646

@@ -83,6 +83,6 @@ func newRichSelect(ptty *ptytest.PTY, opts cliui.RichSelectOptions) (string, err
8383
},
8484
}
8585
cmd.SetOutput(ptty.Output())
86-
cmd.SetIn(ptty.Input())
86+
cmd.Stdin = ptty.Input()
8787
return value, cmd.RunContext(context.Background())
8888
}

cli/delete_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestDelete(t *testing.T) {
5959
pty := ptytest.New(t)
6060
cmd.Stdin = pty.Input()
6161
cmd.Stdout = pty.Output()
62-
cmd.SetErr(pty.Output())
62+
cmd.Stderr = pty.Output()
6363
go func() {
6464
defer close(doneChan)
6565
err := cmd.Run()

cli/gitssh_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func TestGitSSH(t *testing.T) {
230230
// Test authentication via local private key.
231231
cmd, _ := clitest.New(t, cmdArgs...)
232232
cmd.Stdout = pty.Output()
233-
cmd.SetErr(pty.Output())
233+
cmd.Stderr = pty.Output()
234234
err = cmd.WithContext(ctx).Run()
235235
require.NoError(t, err)
236236
select {
@@ -247,7 +247,7 @@ func TestGitSSH(t *testing.T) {
247247
// With the local file deleted, the coder key should be used.
248248
cmd, _ = clitest.New(t, cmdArgs...)
249249
cmd.Stdout = pty.Output()
250-
cmd.SetErr(pty.Output())
250+
cmd.Stderr = pty.Output()
251251
err = cmd.WithContext(ctx).Run()
252252
require.NoError(t, err)
253253
select {

cli/list_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestList(t *testing.T) {
6464
defer cancelFunc()
6565

6666
out := bytes.NewBuffer(nil)
67-
cmd.SetOut(out)
67+
cmd.Stdout = out
6868
err := cmd.WithContext(ctx).Run()
6969
require.NoError(t, err)
7070

cli/login_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ func TestLogin(t *testing.T) {
2020
t.Parallel()
2121
client := coderdtest.New(t, nil)
2222
root, _ := clitest.New(t, "login", client.URL.String())
23-
err := root.Execute()
23+
err := root.Run()
2424
require.Error(t, err)
2525
})
2626

2727
t.Run("InitialUserBadLoginURL", func(t *testing.T) {
2828
t.Parallel()
2929
badLoginURL := "https://fcca2077f06e68aaf9"
3030
root, _ := clitest.New(t, "login", badLoginURL)
31-
err := root.Execute()
31+
err := root.Run()
3232
errMsg := fmt.Sprintf("Failed to check server %q for first user, is the URL correct and is coder accessible from your browser?", badLoginURL)
3333
require.ErrorContains(t, err, errMsg)
3434
})
@@ -42,11 +42,11 @@ func TestLogin(t *testing.T) {
4242
doneChan := make(chan struct{})
4343
root, _ := clitest.New(t, "login", "--force-tty", client.URL.String())
4444
pty := ptytest.New(t)
45-
root.SetIn(pty.Input())
46-
root.SetOut(pty.Output())
45+
root.Stdin = pty.Input()
46+
root.Stdout = pty.Output()
4747
go func() {
4848
defer close(doneChan)
49-
err := root.Execute()
49+
err := root.Run()
5050
assert.NoError(t, err)
5151
}()
5252

@@ -77,11 +77,11 @@ func TestLogin(t *testing.T) {
7777
doneChan := make(chan struct{})
7878
root, _ := clitest.New(t, "--url", client.URL.String(), "login", "--force-tty")
7979
pty := ptytest.New(t)
80-
root.SetIn(pty.Input())
81-
root.SetOut(pty.Output())
80+
root.Stdin = pty.Input()
81+
root.Stdout = pty.Output()
8282
go func() {
8383
defer close(doneChan)
84-
err := root.Execute()
84+
err := root.Run()
8585
assert.NoError(t, err)
8686
}()
8787

@@ -109,11 +109,11 @@ func TestLogin(t *testing.T) {
109109
doneChan := make(chan struct{})
110110
root, _ := clitest.New(t, "login", client.URL.String(), "--first-user-username", "testuser", "--first-user-email", "user@coder.com", "--first-user-password", "SomeSecurePassword!", "--first-user-trial")
111111
pty := ptytest.New(t)
112-
root.SetIn(pty.Input())
113-
root.SetOut(pty.Output())
112+
root.Stdin = pty.Input()
113+
root.Stdout = pty.Output()
114114
go func() {
115115
defer close(doneChan)
116-
err := root.Execute()
116+
err := root.Run()
117117
assert.NoError(t, err)
118118
}()
119119
pty.ExpectMatch("Welcome to Coder")
@@ -131,11 +131,11 @@ func TestLogin(t *testing.T) {
131131
doneChan := make(chan struct{})
132132
root, _ := clitest.New(t, "login", "--force-tty", client.URL.String())
133133
pty := ptytest.New(t)
134-
root.SetIn(pty.Input())
135-
root.SetOut(pty.Output())
134+
root.Stdin = pty.Input()
135+
root.Stdout = pty.Output()
136136
go func() {
137137
defer close(doneChan)
138-
err := root.ExecuteContext(ctx)
138+
err := root.WithContext(ctx).Run()
139139
assert.NoError(t, err)
140140
}()
141141

@@ -174,11 +174,11 @@ func TestLogin(t *testing.T) {
174174
doneChan := make(chan struct{})
175175
root, _ := clitest.New(t, "login", "--force-tty", client.URL.String(), "--no-open")
176176
pty := ptytest.New(t)
177-
root.SetIn(pty.Input())
178-
root.SetOut(pty.Output())
177+
root.Stdin = pty.Input()
178+
root.Stdout = pty.Output()
179179
go func() {
180180
defer close(doneChan)
181-
err := root.Execute()
181+
err := root.Run()
182182
assert.NoError(t, err)
183183
}()
184184

@@ -198,11 +198,11 @@ func TestLogin(t *testing.T) {
198198
doneChan := make(chan struct{})
199199
root, _ := clitest.New(t, "login", client.URL.String(), "--no-open")
200200
pty := ptytest.New(t)
201-
root.SetIn(pty.Input())
202-
root.SetOut(pty.Output())
201+
root.Stdin = pty.Input()
202+
root.Stdout = pty.Output()
203203
go func() {
204204
defer close(doneChan)
205-
err := root.ExecuteContext(ctx)
205+
err := root.WithContext(ctx).Run()
206206
// An error is expected in this case, since the login wasn't successful:
207207
assert.Error(t, err)
208208
}()
@@ -219,7 +219,7 @@ func TestLogin(t *testing.T) {
219219
client := coderdtest.New(t, nil)
220220
coderdtest.CreateFirstUser(t, client)
221221
root, cfg := clitest.New(t, "login", client.URL.String(), "--token", client.SessionToken())
222-
err := root.Execute()
222+
err := root.Run()
223223
require.NoError(t, err)
224224
sessionFile, err := cfg.Session().Read()
225225
require.NoError(t, err)

cli/logout_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ func TestLogout(t *testing.T) {
3030

3131
logoutChan := make(chan struct{})
3232
logout, _ := clitest.New(t, "logout", "--global-config", string(config))
33-
logout.SetIn(pty.Input())
34-
logout.SetOut(pty.Output())
33+
logout.Stdin = pty.Input()
34+
logout.Stdout = pty.Output()
3535

3636
go func() {
3737
defer close(logoutChan)
38-
err := logout.Execute()
38+
err := logout.Run()
3939
assert.NoError(t, err)
4040
assert.NoFileExists(t, string(config.URL()))
4141
assert.NoFileExists(t, string(config.Session()))
@@ -58,12 +58,12 @@ func TestLogout(t *testing.T) {
5858

5959
logoutChan := make(chan struct{})
6060
logout, _ := clitest.New(t, "logout", "--global-config", string(config), "-y")
61-
logout.SetIn(pty.Input())
62-
logout.SetOut(pty.Output())
61+
logout.Stdin = pty.Input()
62+
logout.Stdout = pty.Output()
6363

6464
go func() {
6565
defer close(logoutChan)
66-
err := logout.Execute()
66+
err := logout.Run()
6767
assert.NoError(t, err)
6868
assert.NoFileExists(t, string(config.URL()))
6969
assert.NoFileExists(t, string(config.Session()))
@@ -88,12 +88,12 @@ func TestLogout(t *testing.T) {
8888
logoutChan := make(chan struct{})
8989
logout, _ := clitest.New(t, "logout", "--global-config", string(config))
9090

91-
logout.SetIn(pty.Input())
92-
logout.SetOut(pty.Output())
91+
logout.Stdin = pty.Input()
92+
logout.Stdout = pty.Output()
9393

9494
go func() {
9595
defer close(logoutChan)
96-
err := logout.Execute()
96+
err := logout.Run()
9797
assert.EqualError(t, err, "You are not logged in. Try logging in using 'coder login <url>'.")
9898
}()
9999

@@ -115,12 +115,12 @@ func TestLogout(t *testing.T) {
115115
logoutChan := make(chan struct{})
116116
logout, _ := clitest.New(t, "logout", "--global-config", string(config))
117117

118-
logout.SetIn(pty.Input())
119-
logout.SetOut(pty.Output())
118+
logout.Stdin = pty.Input()
119+
logout.Stdout = pty.Output()
120120

121121
go func() {
122122
defer close(logoutChan)
123-
err = logout.Execute()
123+
err = logout.Run()
124124
assert.EqualError(t, err, "You are not logged in. Try logging in using 'coder login <url>'.")
125125
}()
126126

@@ -169,12 +169,12 @@ func TestLogout(t *testing.T) {
169169
logoutChan := make(chan struct{})
170170
logout, _ := clitest.New(t, "logout", "--global-config", string(config))
171171

172-
logout.SetIn(pty.Input())
173-
logout.SetOut(pty.Output())
172+
logout.Stdin = pty.Input()
173+
logout.Stdout = pty.Output()
174174

175175
go func() {
176176
defer close(logoutChan)
177-
err := logout.Execute()
177+
err := logout.Run()
178178
assert.NotNil(t, err)
179179
var errorMessage string
180180
if runtime.GOOS == "windows" {
@@ -200,11 +200,11 @@ func login(t *testing.T, pty *ptytest.PTY) config.Root {
200200

201201
doneChan := make(chan struct{})
202202
root, cfg := clitest.New(t, "login", "--force-tty", client.URL.String(), "--no-open")
203-
root.SetIn(pty.Input())
204-
root.SetOut(pty.Output())
203+
root.Stdin = pty.Input()
204+
root.Stdout = pty.Output()
205205
go func() {
206206
defer close(doneChan)
207-
err := root.Execute()
207+
err := root.Run()
208208
assert.NoError(t, err)
209209
}()
210210

0 commit comments

Comments
 (0)