Skip to content

Commit d6e131c

Browse files
committed
Appease linter/fmt
Signed-off-by: Spike Curtis <spike@coder.com>
1 parent 90bfe94 commit d6e131c

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

pty/start_other_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ var argEcho = []string{"test"}
7171

7272
// these constants/vars are used by Test_Start_truncate
7373

74-
const countEnd = 1000
75-
const cmdCount = "sh"
74+
const (
75+
countEnd = 1000
76+
cmdCount = "sh"
77+
)
7678

7779
var argCount = []string{"-c", `
7880
i=0

pty/start_test.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@ import (
88
"os/exec"
99
"strings"
1010
"testing"
11-
"time"
1211

13-
"github.com/coder/coder/pty"
1412
"github.com/hinshun/vt10x"
1513
"github.com/stretchr/testify/assert"
1614
"github.com/stretchr/testify/require"
15+
16+
"github.com/coder/coder/pty"
17+
"github.com/coder/coder/testutil"
1718
)
1819

1920
// Test_Start_copy tests that we can use io.Copy() on command output
2021
// without deadlocking.
2122
func Test_Start_copy(t *testing.T) {
2223
t.Parallel()
2324

24-
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
25+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
2526
defer cancel()
2627

2728
pc, cmd, err := pty.Start(exec.CommandContext(ctx, cmdEcho, argEcho...))
@@ -54,12 +55,12 @@ func Test_Start_copy(t *testing.T) {
5455
}
5556
}
5657

57-
// Test_Start_truncation tests that we can read command ouput without truncation
58+
// Test_Start_truncation tests that we can read command output without truncation
5859
// even after the command has exited.
5960
func Test_Start_trucation(t *testing.T) {
6061
t.Parallel()
6162

62-
ctx, cancel := context.WithTimeout(context.Background(), time.Second*1000)
63+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
6364
defer cancel()
6465

6566
pc, cmd, err := pty.Start(exec.CommandContext(ctx, cmdCount, argCount...))
@@ -73,7 +74,10 @@ func Test_Start_trucation(t *testing.T) {
7374
for n < countEnd-25 {
7475
want := fmt.Sprintf("%d", n)
7576
err := readUntil(ctx, t, want, pc.OutputReader())
76-
require.NoError(t, err, "want: %s", want)
77+
assert.NoError(t, err, "want: %s", want)
78+
if err != nil {
79+
return
80+
}
7781
n++
7882
}
7983
}()
@@ -106,14 +110,16 @@ func Test_Start_trucation(t *testing.T) {
106110
for n <= countEnd {
107111
want := fmt.Sprintf("%d", n)
108112
err := readUntil(ctx, t, want, pc.OutputReader())
109-
require.NoError(t, err, "want: %s", want)
113+
assert.NoError(t, err, "want: %s", want)
114+
if err != nil {
115+
return
116+
}
110117
n++
111118
}
112119
// ensure we still get to EOF
113120
endB := &bytes.Buffer{}
114121
_, err := io.Copy(endB, pc.OutputReader())
115-
require.NoError(t, err)
116-
122+
assert.NoError(t, err)
117123
}()
118124

119125
select {

pty/start_windows_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ var argEcho = []string{"/c", "echo", "test"}
6060

6161
// these constants/vars are used by Test_Start_truncate
6262

63-
const countEnd = 1000
64-
const cmdCount = "cmd.exe"
63+
const (
64+
countEnd = 1000
65+
cmdCount = "cmd.exe"
66+
)
6567

6668
var argCount = []string{"/c", fmt.Sprintf("for /L %%n in (1,1,%d) do @echo %%n", countEnd)}

0 commit comments

Comments
 (0)