mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-26 10:20:29 +00:00
34 lines
772 B
Go
34 lines
772 B
Go
package ssh
|
|
|
|
import (
|
|
"net"
|
|
"testing"
|
|
)
|
|
|
|
func testClientVersion(t *testing.T, config *ClientConfig, expected string) {
|
|
clientConn, serverConn := net.Pipe()
|
|
receivedVersion := make(chan string, 1)
|
|
go func() {
|
|
version, err := readVersion(serverConn)
|
|
if err != nil {
|
|
receivedVersion <- ""
|
|
} else {
|
|
receivedVersion <- string(version)
|
|
}
|
|
serverConn.Close()
|
|
}()
|
|
Client(clientConn, config)
|
|
actual := <-receivedVersion
|
|
if actual != expected {
|
|
t.Fatalf("got %s; want %s", actual, expected)
|
|
}
|
|
}
|
|
|
|
func TestCustomClientVersion(t *testing.T) {
|
|
version := "Test-Client-Version-0.0"
|
|
testClientVersion(t, &ClientConfig{ClientVersion: version}, version)
|
|
}
|
|
|
|
func TestDefaultClientVersion(t *testing.T) {
|
|
testClientVersion(t, &ClientConfig{}, packageVersion)
|
|
}
|