Skip to content

Commit

Permalink
ssh: CL feedback on test
Browse files Browse the repository at this point in the history
  • Loading branch information
ydnar committed Jun 22, 2023
1 parent d051e97 commit ce9c179
Showing 1 changed file with 16 additions and 31 deletions.
47 changes: 16 additions & 31 deletions ssh/test/dial_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,23 @@ func testDial(t *testing.T, n, listenAddr string, x dialTester) {
}
}()

{
conn, err := sshConn.Dial(n, l.Addr().String())
if err != nil {
t.Fatalf("Dial: %v", err)
}
x.TestClientConn(t, conn)
defer conn.Close()
b, err := io.ReadAll(conn)
if err != nil {
t.Fatalf("ReadAll: %v", err)
}
t.Logf("got %q", string(b))
if string(b) != testData {
t.Fatalf("expected %q, got %q", testData, string(b))
}
ctx, cancel := context.WithCancel(context.Background())
conn, err := sshConn.DialContext(ctx, n, l.Addr().String())
// Canceling the context after dial should have no effect
// on the opened connection.
cancel()
if err != nil {
t.Fatalf("Dial: %v", err)
}

{
conn, err := sshConn.DialContext(context.Background(), n, l.Addr().String())
if err != nil {
t.Fatalf("Dial: %v", err)
}
x.TestClientConn(t, conn)
defer conn.Close()
b, err := io.ReadAll(conn)
if err != nil {
t.Fatalf("ReadAll: %v", err)
}
t.Logf("got %q", string(b))
if string(b) != testData {
t.Fatalf("expected %q, got %q", testData, string(b))
}
x.TestClientConn(t, conn)
defer conn.Close()
b, err := io.ReadAll(conn)
if err != nil {
t.Fatalf("ReadAll: %v", err)
}
t.Logf("got %q", string(b))
if string(b) != testData {
t.Fatalf("expected %q, got %q", testData, string(b))
}
}

Expand Down

0 comments on commit ce9c179

Please sign in to comment.