| // Copyright 2014 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. |
| func testClientVersion(t *testing.T, config *ClientConfig, expected string) { |
| clientConn, serverConn := net.Pipe() |
| receivedVersion := make(chan string, 1) |
| version, err := readVersion(serverConn) |
| receivedVersion <- string(version) |
| NewClientConn(clientConn, "", config) |
| actual := <-receivedVersion |
| 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) |