Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf9da263

Browse files
authored
test(cli): Fix portforward test timeouts (#7241)
1 parentf39e6a7 commitf9da263

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

‎cli/portforward_test.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@ import (
2121
"github.com/coder/coder/testutil"
2222
)
2323

24-
//nolint:tparallel,paralleltest // Subtests require setup that must not be done in parallel.
25-
funcTestPortForward(t*testing.T) {
26-
t.Run("None",func(t*testing.T) {
27-
t.Parallel()
24+
funcTestPortForward_None(t*testing.T) {
25+
t.Parallel()
2826

29-
client:=coderdtest.New(t,nil)
30-
_=coderdtest.CreateFirstUser(t,client)
27+
client:=coderdtest.New(t,nil)
28+
_=coderdtest.CreateFirstUser(t,client)
3129

32-
inv,root:=clitest.New(t,"port-forward","blah")
33-
clitest.SetupConfig(t,client,root)
34-
pty:=ptytest.New(t).Attach(inv)
35-
inv.Stderr=pty.Output()
30+
inv,root:=clitest.New(t,"port-forward","blah")
31+
clitest.SetupConfig(t,client,root)
32+
pty:=ptytest.New(t).Attach(inv)
33+
inv.Stderr=pty.Output()
3634

37-
err:=inv.Run()
38-
require.Error(t,err)
39-
require.ErrorContains(t,err,"no port-forwards")
35+
err:=inv.Run()
36+
require.Error(t,err)
37+
require.ErrorContains(t,err,"no port-forwards")
4038

41-
// Check that the help was printed.
42-
pty.ExpectMatch("port-forward <workspace>")
43-
})
39+
// Check that the help was printed.
40+
pty.ExpectMatch("port-forward <workspace>")
41+
}
4442

43+
//nolint:tparallel,paralleltest // Subtests require setup that must not be done in parallel.
44+
funcTestPortForward(t*testing.T) {
4545
cases:= []struct {
4646
namestring
4747
networkstring
@@ -134,13 +134,13 @@ func TestPortForward(t *testing.T) {
134134
inv.Stdin=pty.Input()
135135
inv.Stdout=pty.Output()
136136
inv.Stderr=pty.Output()
137-
ctx,cancel:=context.WithCancel(context.Background())
137+
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
138138
defercancel()
139139
errC:=make(chanerror)
140140
gofunc() {
141141
errC<-inv.WithContext(ctx).Run()
142142
}()
143-
pty.ExpectMatch("Ready!")
143+
pty.ExpectMatchContext(ctx,"Ready!")
144144

145145
t.Parallel()// Port is reserved, enable parallel execution.
146146

@@ -181,13 +181,13 @@ func TestPortForward(t *testing.T) {
181181
inv.Stdin=pty.Input()
182182
inv.Stdout=pty.Output()
183183
inv.Stderr=pty.Output()
184-
ctx,cancel:=context.WithCancel(context.Background())
184+
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
185185
defercancel()
186186
errC:=make(chanerror)
187187
gofunc() {
188188
errC<-inv.WithContext(ctx).Run()
189189
}()
190-
pty.ExpectMatch("Ready!")
190+
pty.ExpectMatchContext(ctx,"Ready!")
191191

192192
t.Parallel()// Port is reserved, enable parallel execution.
193193

@@ -234,13 +234,13 @@ func TestPortForward(t *testing.T) {
234234
clitest.SetupConfig(t,client,root)
235235
pty:=ptytest.New(t).Attach(inv)
236236
inv.Stderr=pty.Output()
237-
ctx,cancel:=context.WithCancel(context.Background())
237+
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
238238
defercancel()
239239
errC:=make(chanerror)
240240
gofunc() {
241241
errC<-inv.WithContext(ctx).Run()
242242
}()
243-
pty.ExpectMatch("Ready!")
243+
pty.ExpectMatchContext(ctx,"Ready!")
244244

245245
t.Parallel()// Port is reserved, enable parallel execution.
246246

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp