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

test(cli): Fix portforward test timeouts#7241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mafredri merged 1 commit intomainfrommafredri/cli-first-portforward-timeouts
Apr 21, 2023
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletionscli/portforward_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,27 +21,27 @@ import (
"github.com/coder/coder/testutil"
)

//nolint:tparallel,paralleltest // Subtests require setup that must not be done in parallel.
func TestPortForward(t *testing.T) {
t.Run("None", func(t *testing.T) {
t.Parallel()
func TestPortForward_None(t *testing.T) {
t.Parallel()

client := coderdtest.New(t, nil)
_ = coderdtest.CreateFirstUser(t, client)
client := coderdtest.New(t, nil)
_ = coderdtest.CreateFirstUser(t, client)

inv, root := clitest.New(t, "port-forward", "blah")
clitest.SetupConfig(t, client, root)
pty := ptytest.New(t).Attach(inv)
inv.Stderr = pty.Output()
inv, root := clitest.New(t, "port-forward", "blah")
clitest.SetupConfig(t, client, root)
pty := ptytest.New(t).Attach(inv)
inv.Stderr = pty.Output()

err := inv.Run()
require.Error(t, err)
require.ErrorContains(t, err, "no port-forwards")
err := inv.Run()
require.Error(t, err)
require.ErrorContains(t, err, "no port-forwards")

// Check that the help was printed.
pty.ExpectMatch("port-forward <workspace>")
})
// Check that the help was printed.
pty.ExpectMatch("port-forward <workspace>")
}

//nolint:tparallel,paralleltest // Subtests require setup that must not be done in parallel.
func TestPortForward(t *testing.T) {
cases := []struct {
name string
network string
Expand DownExpand Up@@ -134,13 +134,13 @@ func TestPortForward(t *testing.T) {
inv.Stdin = pty.Input()
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
errC := make(chan error)
go func() {
errC <- inv.WithContext(ctx).Run()
}()
pty.ExpectMatch("Ready!")
pty.ExpectMatchContext(ctx,"Ready!")

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

Expand DownExpand Up@@ -181,13 +181,13 @@ func TestPortForward(t *testing.T) {
inv.Stdin = pty.Input()
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
errC := make(chan error)
go func() {
errC <- inv.WithContext(ctx).Run()
}()
pty.ExpectMatch("Ready!")
pty.ExpectMatchContext(ctx,"Ready!")

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

Expand DownExpand Up@@ -234,13 +234,13 @@ func TestPortForward(t *testing.T) {
clitest.SetupConfig(t, client, root)
pty := ptytest.New(t).Attach(inv)
inv.Stderr = pty.Output()
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
errC := make(chan error)
go func() {
errC <- inv.WithContext(ctx).Run()
}()
pty.ExpectMatch("Ready!")
pty.ExpectMatchContext(ctx,"Ready!")

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

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp