1
// Copyright 2014 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
12
func testClientVersion(t *testing.T, config *ClientConfig, expected string) {
13
clientConn, serverConn := net.Pipe()
14
defer clientConn.Close()
15
receivedVersion := make(chan string, 1)
17
version, err := readVersion(serverConn)
21
receivedVersion <- string(version)
25
NewClientConn(clientConn, "", config)
26
actual := <-receivedVersion
27
if actual != expected {
28
t.Fatalf("got %s; want %s", actual, expected)
32
func TestCustomClientVersion(t *testing.T) {
33
version := "Test-Client-Version-0.0"
34
testClientVersion(t, &ClientConfig{ClientVersion: version}, version)
37
func TestDefaultClientVersion(t *testing.T) {
38
testClientVersion(t, &ClientConfig{}, packageVersion)