src.dualinventive.com/go/mtinfo-go/client_test.go

37 lines
836 B
Go

package mtinfo
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewClient_withGRPCProtocol_returnsGRPCClient(t *testing.T) {
cfg := Config{
Auth: AuthConfig{
PublicKey: "testdata/key_rsa.pub",
Grpc: GrpcEndpoint{
Host: "localhost",
Port: "1234",
},
},
}
client, err := NewClient(GRPC, cfg)
assert.Nil(t, err)
assert.NotNil(t, client)
assert.NotNil(t, client.Auth)
assert.IsType(t, client.Auth, &grpcAuthServiceClient{})
}
func TestNewClient_withRESTProtocol_returnsNotYetImplemented(t *testing.T) {
cfg := Config{}
_, err := NewClient(REST, cfg)
assert.EqualError(t, err, "not yet implemented")
}
func TestNewClient_withUnknownProtocol_returnsError(t *testing.T) {
cfg := Config{}
_, err := NewClient(Protocol("udp"), cfg)
assert.EqualError(t, err, "protocol not supported")
}