Skip to content
Merged
Changes from all 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 deletions cli/portforward_test.go
Original file line number Diff line number Diff 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 Down Expand 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 Down Expand 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 Down Expand 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