From 76b6082f1c20ddb1362a9475d50478f07d0730f0 Mon Sep 17 00:00:00 2001 From: snoop Date: Wed, 21 Jun 2017 11:50:14 +0900 Subject: [PATCH] added test --- gateway/services.go | 4 +++- server/rpc_test.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gateway/services.go b/gateway/services.go index 0c8c261..a139ca7 100644 --- a/gateway/services.go +++ b/gateway/services.go @@ -21,6 +21,8 @@ import ( "git.loafle.net/overflow/overflow_proxy_service/proxy/sensorItemMapping" "log" "git.loafle.net/overflow/overflow_proxy_service/proxy/agent" + //"google.golang.org/grpc/metadata" + ) var g_services map[string]interface{} @@ -62,7 +64,7 @@ type ServiceImpl struct { func (s *ServiceImpl) ExecServices(c context.Context, in *pb.ServiceInput) (*pb.ServiceOutput, error) { // Check Service Name serviceName, ok := g_services[in.ServiceName] - + //metadata.FromContext(c) log.Println("Service Name : " + in.ServiceName + " MethodName : " + in.MethodName) if !ok { diff --git a/server/rpc_test.go b/server/rpc_test.go index d0166f4..0cb5853 100644 --- a/server/rpc_test.go +++ b/server/rpc_test.go @@ -12,6 +12,9 @@ import ( "bytes" "io/ioutil" "log" + "google.golang.org/grpc" + pb "git.loafle.net/overflow/overflow_api_service/grpc" + "golang.org/x/net/context" ) func startRpcServerTest() <- chan error{ @@ -86,4 +89,31 @@ func TestRpcServer(t *testing.T) { log.Println( status) os.Exit(1) } +} + + +func TestRPC(t *testing.T) { + + + conn, err := grpc.Dial(":9090", grpc.WithInsecure()); + + if err != nil { + t.Log(err) + } + + + client := pb.NewOverflowGatewayClient(conn) + + si := pb.ServiceInput{} + si.MethodName = "create" + si.ServiceName = "member" + si.Param = make(map[string]string) + si.Param["1"] = "2222" + + so, err := client.ExecServices(context.Background(), &si) + + t.Log(so.ResultStr) + + + } \ No newline at end of file