From 464e53f86cdf2dea4afe3d2778f281ca6b17c05b Mon Sep 17 00:00:00 2001 From: Kevin Park Date: Thu, 7 Dec 2023 14:49:45 +0900 Subject: [PATCH] Revise client mock test --- admin/client.go | 6 +++++- client/client.go | 6 +++++- client/client_test.go | 3 +-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/admin/client.go b/admin/client.go index 9225170fa..e9b2ea48f 100644 --- a/admin/client.go +++ b/admin/client.go @@ -123,8 +123,12 @@ func Dial(rpcAddr string, opts ...Option) (*Client, error) { // Dial dials to the admin service. func (c *Client) Dial(rpcAddr string) error { + if !strings.HasPrefix(rpcAddr, "http") { + rpcAddr = "http://" + rpcAddr + } + c.conn = http.DefaultClient - c.client = v1connect.NewAdminServiceClient(c.conn, "http://"+rpcAddr, connect.WithInterceptors(c.authInterceptor)) + c.client = v1connect.NewAdminServiceClient(c.conn, rpcAddr, connect.WithInterceptors(c.authInterceptor)) return nil } diff --git a/client/client.go b/client/client.go index 09f8e520c..f6e5846db 100644 --- a/client/client.go +++ b/client/client.go @@ -181,8 +181,12 @@ func Dial(rpcAddr string, opts ...Option) (*Client, error) { // Dial dials the given rpcAddr. func (c *Client) Dial(rpcAddr string) error { + if !strings.HasPrefix(rpcAddr, "http") { + rpcAddr = "http://" + rpcAddr + } + c.conn = http.DefaultClient - c.client = v1connect.NewYorkieServiceClient(c.conn, "http://"+rpcAddr, c.clientOptions...) + c.client = v1connect.NewYorkieServiceClient(c.conn, rpcAddr, c.clientOptions...) return nil } diff --git a/client/client_test.go b/client/client_test.go index 7d689a160..1261474cd 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -26,7 +26,6 @@ import ( "testing" "connectrpc.com/connect" - "github.com/rs/xid" "github.com/stretchr/testify/assert" monkey "github.com/undefinedlabs/go-mpatch" @@ -47,7 +46,7 @@ type testYorkieServer struct { func dialTestYorkieServer() (*testYorkieServer, string) { yorkieServer := &v1connect.UnimplementedYorkieServiceHandler{} mux := http.NewServeMux() - mux.Handle(v1connect.NewYorkieServiceHandler(yorkieServer, nil)) + mux.Handle(v1connect.NewYorkieServiceHandler(yorkieServer)) httpServer := httptest.NewUnstartedServer(mux) testYorkieServer := &testYorkieServer{