forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
41 lines (33 loc) · 1.04 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2015 Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package goclienttest
import (
"testing"
"time"
"github.com/youtube/vitess/go/vt/vtgate/vtgateconn"
"golang.org/x/net/context"
)
const connectionKeyspace = "conn_ks"
// This file contains the reference test for clients. It tests
// all the corner cases of the API, and makes sure the go client
// is full featured.
//
// It can be used as a template by other languages for their test suites.
//
// TODO(team) add more unit test cases.
// TestGoClient runs the test suite for the provided client
func TestGoClient(t *testing.T, protocol, addr string) {
// Create a client connecting to the server
ctx := context.Background()
conn, err := vtgateconn.DialProtocol(ctx, protocol, addr, 30*time.Second, connectionKeyspace)
if err != nil {
t.Fatalf("dial failed: %v", err)
}
testCallerID(t, conn)
testEcho(t, conn)
testErrors(t, conn)
testSuccess(t, conn)
// and clean up
conn.Close()
}