Add testdata package and unify testdata to only one dir (#1297)

This commit is contained in:
田欧
2017-07-26 01:24:45 +08:00
committed by Menghan Li
parent a56843968d
commit ca9e0c3458
33 changed files with 91 additions and 410 deletions

View File

@ -24,6 +24,7 @@ import (
"testing"
"golang.org/x/net/context"
"google.golang.org/grpc/testdata"
)
func TestTLSOverrideServerName(t *testing.T) {
@ -50,8 +51,6 @@ func TestTLSClone(t *testing.T) {
}
const tlsDir = "../test/testdata/"
type serverHandshake func(net.Conn) (AuthInfo, error)
func TestClientHandshakeReturnsAuthInfo(t *testing.T) {
@ -162,7 +161,7 @@ func clientHandle(t *testing.T, hs func(net.Conn, string) (AuthInfo, error), lis
// Server handshake implementation in gRPC.
func gRPCServerHandshake(conn net.Conn) (AuthInfo, error) {
serverTLS, err := NewServerTLSFromFile(tlsDir+"server1.pem", tlsDir+"server1.key")
serverTLS, err := NewServerTLSFromFile(testdata.Path("server1.pem"), testdata.Path("server1.key"))
if err != nil {
return nil, err
}
@ -184,7 +183,7 @@ func gRPCClientHandshake(conn net.Conn, lisAddr string) (AuthInfo, error) {
}
func tlsServerHandshake(conn net.Conn) (AuthInfo, error) {
cert, err := tls.LoadX509KeyPair(tlsDir+"server1.pem", tlsDir+"server1.key")
cert, err := tls.LoadX509KeyPair(testdata.Path("server1.pem"), testdata.Path("server1.key"))
if err != nil {
return nil, err
}