Skip to content

Commit 483d43d

Browse files
committed
fix(session): remove duplicate Stderr definitions
Add session.Stderr test Fixes: 993008d ("refactor: keeping the same Stderr method")
1 parent e845afe commit 483d43d

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

session.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ type Session interface {
8282
// the request handling loop. Registering nil will unregister the channel.
8383
// During the time that no channel is registered, breaks are ignored.
8484
Break(c chan<- bool)
85-
86-
// Stderr returns an io.ReadWriter that writes to this channel
87-
// with the extended data type set to stderr. Stderr may
88-
// safely be read and written from a different goroutine than
89-
// Read and Write respectively.
90-
Stderr() io.ReadWriter
9185
}
9286

9387
// maxSigBufSize is how many signals will be buffered

session_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,30 @@ func TestStderr(t *testing.T) {
108108
}
109109
}
110110

111+
func TestPtyStderr(t *testing.T) {
112+
t.Parallel()
113+
testBytes := []byte("Hello world\n\r\n")
114+
expectBytes := []byte("Hello world\r\n\r\n")
115+
session, _, cleanup := newTestSession(t, &Server{
116+
Handler: func(s Session) {
117+
s.Stderr().Write(testBytes)
118+
},
119+
}, nil)
120+
err := session.RequestPty("xterm", 80, 40, nil)
121+
if err != nil {
122+
t.Fatal(err)
123+
}
124+
defer cleanup()
125+
var stderr bytes.Buffer
126+
session.Stderr = &stderr
127+
if err := session.Run(""); err != nil {
128+
t.Fatal(err)
129+
}
130+
if !bytes.Equal(stderr.Bytes(), expectBytes) {
131+
t.Fatalf("stderr = %#v; want %#v", stderr.Bytes(), expectBytes)
132+
}
133+
}
134+
111135
func TestStdin(t *testing.T) {
112136
t.Parallel()
113137
testBytes := []byte("Hello world\n")

0 commit comments

Comments
 (0)