Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
a33b7608
Commit
a33b7608
authored
Jan 15, 2012
by
Adam Langley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exp/ssh: patching in the last change lost that a file was deleted.
R=golang-dev CC=golang-dev
https://golang.org/cl/5541060
parent
dd47a0a2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
134 deletions
+0
-134
server_shell_test.go
src/pkg/exp/ssh/server_shell_test.go
+0
-134
No files found.
src/pkg/exp/ssh/server_shell_test.go
deleted
100644 → 0
View file @
dd47a0a2
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
ssh
import
(
"io"
"testing"
)
type
MockChannel
struct
{
toSend
[]
byte
bytesPerRead
int
received
[]
byte
}
func
(
c
*
MockChannel
)
Accept
()
error
{
return
nil
}
func
(
c
*
MockChannel
)
Reject
(
RejectionReason
,
string
)
error
{
return
nil
}
func
(
c
*
MockChannel
)
Read
(
data
[]
byte
)
(
n
int
,
err
error
)
{
n
=
len
(
data
)
if
n
==
0
{
return
}
if
n
>
len
(
c
.
toSend
)
{
n
=
len
(
c
.
toSend
)
}
if
n
==
0
{
return
0
,
io
.
EOF
}
if
c
.
bytesPerRead
>
0
&&
n
>
c
.
bytesPerRead
{
n
=
c
.
bytesPerRead
}
copy
(
data
,
c
.
toSend
[
:
n
])
c
.
toSend
=
c
.
toSend
[
n
:
]
return
}
func
(
c
*
MockChannel
)
Write
(
data
[]
byte
)
(
n
int
,
err
error
)
{
c
.
received
=
append
(
c
.
received
,
data
...
)
return
len
(
data
),
nil
}
func
(
c
*
MockChannel
)
Close
()
error
{
return
nil
}
func
(
c
*
MockChannel
)
AckRequest
(
ok
bool
)
error
{
return
nil
}
func
(
c
*
MockChannel
)
ChannelType
()
string
{
return
""
}
func
(
c
*
MockChannel
)
ExtraData
()
[]
byte
{
return
nil
}
func
TestClose
(
t
*
testing
.
T
)
{
c
:=
&
MockChannel
{}
ss
:=
NewServerShell
(
c
,
"> "
)
line
,
err
:=
ss
.
ReadLine
()
if
line
!=
""
{
t
.
Errorf
(
"Expected empty line but got: %s"
,
line
)
}
if
err
!=
io
.
EOF
{
t
.
Errorf
(
"Error should have been EOF but got: %s"
,
err
)
}
}
var
keyPressTests
=
[]
struct
{
in
string
line
string
err
error
}{
{
""
,
""
,
io
.
EOF
,
},
{
"
\r
"
,
""
,
nil
,
},
{
"foo
\r
"
,
"foo"
,
nil
,
},
{
"a
\x1b
[Cb
\r
"
,
// right
"ab"
,
nil
,
},
{
"a
\x1b
[Db
\r
"
,
// left
"ba"
,
nil
,
},
{
"a
\1
77b
\r
"
,
// backspace
"b"
,
nil
,
},
}
func
TestKeyPresses
(
t
*
testing
.
T
)
{
for
i
,
test
:=
range
keyPressTests
{
for
j
:=
0
;
j
<
len
(
test
.
in
);
j
++
{
c
:=
&
MockChannel
{
toSend
:
[]
byte
(
test
.
in
),
bytesPerRead
:
j
,
}
ss
:=
NewServerShell
(
c
,
"> "
)
line
,
err
:=
ss
.
ReadLine
()
if
line
!=
test
.
line
{
t
.
Errorf
(
"Line resulting from test %d (%d bytes per read) was '%s', expected '%s'"
,
i
,
j
,
line
,
test
.
line
)
break
}
if
err
!=
test
.
err
{
t
.
Errorf
(
"Error resulting from test %d (%d bytes per read) was '%v', expected '%v'"
,
i
,
j
,
err
,
test
.
err
)
break
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment