Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(415)

Delta Between Two Patch Sets: ssh/client_test.go

Issue 14641044: code review 14641044: go.crypto/ssh: put version exchange in function (Closed)
Left Patch Set: diff -r bb19605bfacc https://code.google.com/p/go.crypto Created 10 years, 5 months ago
Right Patch Set: diff -r bb19605bfacc https://code.google.com/p/go.crypto Created 10 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « ssh/client.go ('k') | ssh/server.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package ssh 1 package ssh
2 2
3 import ( 3 import (
4 "net" 4 "net"
5 "testing" 5 "testing"
6 ) 6 )
7 7
8 func testClientVersion(t *testing.T, config *ClientConfig, expected string) { 8 func testClientVersion(t *testing.T, config *ClientConfig, expected string) {
9 clientConn, serverConn := net.Pipe() 9 clientConn, serverConn := net.Pipe()
10 receivedVersion := make(chan string, 1) 10 receivedVersion := make(chan string, 1)
11 go func() { 11 go func() {
12 version, err := readVersion(serverConn) 12 version, err := readVersion(serverConn)
13 if err != nil { 13 if err != nil {
14 receivedVersion <- "" 14 receivedVersion <- ""
15 } else { 15 } else {
16 receivedVersion <- string(version) 16 receivedVersion <- string(version)
17 } 17 }
18 serverConn.Close() 18 serverConn.Close()
19 }() 19 }()
20 Client(clientConn, config) 20 Client(clientConn, config)
21 actual := <-receivedVersion 21 actual := <-receivedVersion
22 if actual != expected { 22 if actual != expected {
23 t.Fatalf("got %s; want %s", actual, expected) 23 t.Fatalf("got %s; want %s", actual, expected)
24 } 24 }
25 } 25 }
26 26
27 func TestCustomClientVersion(t *testing.T) { 27 func TestCustomClientVersion(t *testing.T) {
28 » version := "Test" 28 » version := "Test-Client-Version-0.0"
29 » expect := "SSH-2.0-" + version 29 » testClientVersion(t, &ClientConfig{ClientVersion: version}, version)
30 » testClientVersion(t, &ClientConfig{ClientVersion: version}, expect)
31 } 30 }
32 31
33 func TestDefaultClientVersion(t *testing.T) { 32 func TestDefaultClientVersion(t *testing.T) {
34 » testClientVersion(t, &ClientConfig{}, "SSH-2.0-Go") 33 » testClientVersion(t, &ClientConfig{}, packageVersion)
35 } 34 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b