move test to dedicated repo
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
aa9d104ec4
commit
0fe1f38a2f
8
go.mod
8
go.mod
@ -4,13 +4,13 @@ go 1.15
|
||||
|
||||
require (
|
||||
github.com/golang/protobuf v1.4.2
|
||||
github.com/unistack-org/micro-broker-memory v0.0.0-20200905101815-4594aa2807e9
|
||||
github.com/unistack-org/micro-client-grpc v0.0.0-20200910215954-fef2610f9ce6
|
||||
github.com/google/go-cmp v0.5.1 // indirect
|
||||
github.com/unistack-org/micro-codec-bytes v0.0.0-20200828083432-4e49e953d844
|
||||
github.com/unistack-org/micro-registry-memory v0.0.0-20200905064113-34be66be749f
|
||||
github.com/unistack-org/micro-router-registry v0.0.0-20200920130103-a1ccc75a7761
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200920124807-9b11ea527aeb
|
||||
golang.org/x/net v0.0.0-20200904194848-62affa334b73
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642 // indirect
|
||||
golang.org/x/text v0.3.3 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
google.golang.org/grpc v1.31.1
|
||||
google.golang.org/protobuf v1.25.0
|
||||
)
|
||||
|
26
go.sum
26
go.sum
@ -254,36 +254,12 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||
github.com/timewasted/linode v0.0.0-20160829202747-37e84520dcf7/go.mod h1:imsgLplxEC/etjIhdr3dNzV3JeT27LbVu5pYWm0JCBY=
|
||||
github.com/transip/gotransip v0.0.0-20190812104329-6d8d9179b66f/go.mod h1:i0f4R4o2HM0m3DZYQWsj6/MEowD57VzoH0v3d7igeFY=
|
||||
github.com/uber-go/atomic v1.3.2/go.mod h1:/Ct5t2lcmbJ4OSe/waGBoaVvVqtO0bmtfVNex1PFV8g=
|
||||
github.com/unistack-org/micro-broker-memory v0.0.0-20200905101815-4594aa2807e9 h1:SHiNeIiNjs7BOjmS4tpb3amZKldUTigFiYtWzWOvHCU=
|
||||
github.com/unistack-org/micro-broker-memory v0.0.0-20200905101815-4594aa2807e9/go.mod h1:j19KFne7Y8JvNXHwhjgjVJWAZDoqbnArZTMDEjyVWu0=
|
||||
github.com/unistack-org/micro-client-grpc v0.0.0-20200904205035-ffbb3e990960 h1:MNiHfMdNUWKn6RrFFphYPKjpTCBSH4vGjCglZeUW9Tg=
|
||||
github.com/unistack-org/micro-client-grpc v0.0.0-20200904205035-ffbb3e990960/go.mod h1:we/JUfnT+yZYvZGtMCksPtqGAqqmwUChmrOmAvSf8bE=
|
||||
github.com/unistack-org/micro-client-grpc v0.0.0-20200910215954-fef2610f9ce6 h1:+YjhltzGWFVDEJWypkbl60CcVGUuiagOTiQAOl5kqXM=
|
||||
github.com/unistack-org/micro-client-grpc v0.0.0-20200910215954-fef2610f9ce6/go.mod h1:YDH2dZp7ZeHNvJYDgKEJU67G7tu9+hf701rODFfm5D4=
|
||||
github.com/unistack-org/micro-codec-bytes v0.0.0-20200827104921-3616a69473a6/go.mod h1:g5sOI8TWgGZiVHe8zoUPdtz7+0oLnqTnfBoai6Qb7jE=
|
||||
github.com/unistack-org/micro-codec-bytes v0.0.0-20200828083432-4e49e953d844 h1:5b1yuSllbsMm/9fUIlIXSr8DbsKT/sAKSCgOx6+SAfI=
|
||||
github.com/unistack-org/micro-codec-bytes v0.0.0-20200828083432-4e49e953d844/go.mod h1:g5sOI8TWgGZiVHe8zoUPdtz7+0oLnqTnfBoai6Qb7jE=
|
||||
github.com/unistack-org/micro-config-cmd v0.0.0-20200828075439-d859b9d7265b h1:v5Ak+Sr780jZclFDnx82g5biF0N5HRVKphEpJhbnVUs=
|
||||
github.com/unistack-org/micro-config-cmd v0.0.0-20200828075439-d859b9d7265b/go.mod h1:6pm1cadbwsFcEW1ZbV5Fp0i3goR3TNfROMNSPih3I8k=
|
||||
github.com/unistack-org/micro-config-cmd v0.0.0-20200909210346-ec89783dc46c/go.mod h1:6pm1cadbwsFcEW1ZbV5Fp0i3goR3TNfROMNSPih3I8k=
|
||||
github.com/unistack-org/micro-config-cmd v0.0.0-20200909210755-6e7e85eeab34 h1:VHc98t4SoiCF/jbkFu2e/j+IyJ/+MFQ1T+INNL7LubU=
|
||||
github.com/unistack-org/micro-config-cmd v0.0.0-20200909210755-6e7e85eeab34/go.mod h1:fT1gYn+TtfVZZ5tNx56bZIncJjmlji66g7GKdWua5hE=
|
||||
github.com/unistack-org/micro-registry-memory v0.0.0-20200827091533-c21be2366d55/go.mod h1:F80jL0sIkViezC5CpvJQ4q2+Zzu4fI8zhgyZ+tJdD9o=
|
||||
github.com/unistack-org/micro-registry-memory v0.0.0-20200905064113-34be66be749f h1:aJwqchNCtEYpwCi/Y5MDhQuc1d8RQ5CX7ZgdmFhYeIY=
|
||||
github.com/unistack-org/micro-registry-memory v0.0.0-20200905064113-34be66be749f/go.mod h1:eqAeQoWZMLVScoXEurBfkI5I96Gl1MCN2A/cX1JqaOY=
|
||||
github.com/unistack-org/micro-router-registry v0.0.0-20200828092752-19e0b3a7210f h1:Z76C488sBUdjKLZSNHVqrTpdtkg78GJaiogJFY2mSYA=
|
||||
github.com/unistack-org/micro-router-registry v0.0.0-20200828092752-19e0b3a7210f/go.mod h1:RpBz21l+mF6rK+3iwg8/aDSmixxnymtjqfYcghSMq3w=
|
||||
github.com/unistack-org/micro-router-registry v0.0.0-20200905063806-8285d1378d3c h1:3ClxxLORWg28mQGTttSO0qBrHn6BiIWCEE4ePenkHLc=
|
||||
github.com/unistack-org/micro-router-registry v0.0.0-20200905063806-8285d1378d3c/go.mod h1:p7nD3hq95yfpAYanDRdehcuRxpgFrM28tpeu8DBfygU=
|
||||
github.com/unistack-org/micro-router-registry v0.0.0-20200920130103-a1ccc75a7761 h1:ojJXjWNqSXF6LGkiOKpDp+Cq5pfGcu1EmTBPbyWTYZg=
|
||||
github.com/unistack-org/micro-router-registry v0.0.0-20200920130103-a1ccc75a7761/go.mod h1:mobzF4hd2yI5aZcxdE2Q5bUAGA+g0mV6o/k228berxY=
|
||||
github.com/unistack-org/micro-server-grpc v0.0.0-20200831094349-1205641fc084/go.mod h1:Ky7H+xcszJ//4Z6Tl1Q9iPW+Qy1M+7qPW6ZK4mXayZU=
|
||||
github.com/unistack-org/micro-server-grpc v0.0.0-20200907110628-32734086c27f/go.mod h1:IX1U33kvgx7wgV3avEjHUi8UALCZsveNLbLnZbxMFp4=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-20200827081802-b4ccde222831/go.mod h1:rPQbnry3nboAnMczj8B1Gzlcyv/HYoMZLgd3/3nttJ4=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-20200827083227-aa99378adc6e/go.mod h1:rPQbnry3nboAnMczj8B1Gzlcyv/HYoMZLgd3/3nttJ4=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-20200828085518-2c136b005edd/go.mod h1:fMA60jjS3INPT4AwYm2+jTHVuWEkVYvaO/7wgEpylTk=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-20200831085130-7c115823a7ab/go.mod h1:iEtpu3wTYCRs3pQ3VsFEO7JBO4lOMpkOwMyrpZyIDPo=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200904234316-e7d418183b62/go.mod h1:mB0h+i3Sa4jD8G2dv97cAAdyh01hVQWKw4xSdmTpyOo=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200909210629-caec730248b1/go.mod h1:mmqHR9WelHUXqg2mELjsQ+FJHcWs6mNmXg+wEYO2T3c=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200920124807-9b11ea527aeb h1:ETCShJ27nTE7kMQgaf7S6p1Tbfr2tdGO6MYxZ2LTMWY=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200920124807-9b11ea527aeb/go.mod h1:HUzMG4Mcy97958VxWTg8zuazZgwQ/aoLZ8wtBVONwRE=
|
||||
@ -350,7 +326,6 @@ golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191027093000-83d349e8ac1a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
|
||||
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@ -441,7 +416,6 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98
|
||||
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d h1:92D1fum1bJLKSdr11OJ+54YeCMCGYIygTA7R/YZxH5M=
|
||||
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
|
107
grpc_test.go
107
grpc_test.go
@ -1,107 +0,0 @@
|
||||
package grpc_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
bmemory "github.com/unistack-org/micro-broker-memory"
|
||||
gclient "github.com/unistack-org/micro-client-grpc"
|
||||
rmemory "github.com/unistack-org/micro-registry-memory"
|
||||
regRouter "github.com/unistack-org/micro-router-registry"
|
||||
gserver "github.com/unistack-org/micro-server-grpc"
|
||||
pberr "github.com/unistack-org/micro-server-grpc/errors"
|
||||
pb "github.com/unistack-org/micro-server-grpc/proto"
|
||||
"github.com/unistack-org/micro/v3/broker"
|
||||
"github.com/unistack-org/micro/v3/client"
|
||||
"github.com/unistack-org/micro/v3/router"
|
||||
"github.com/unistack-org/micro/v3/server"
|
||||
)
|
||||
|
||||
type testServer struct {
|
||||
pb.UnimplementedTestServer
|
||||
}
|
||||
|
||||
/*
|
||||
func (g *testServer) Call(ctx context.Context, req *pb.Request, rsp *pb.Response) error {
|
||||
if req.Name == "Error" {
|
||||
st := status.New(codes.InvalidArgument, "error request")
|
||||
st, err := st.WithDetails(&pberr.Error{Id: "id", Code: 99, Detail: "detail"})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return st.Err()
|
||||
}
|
||||
rsp = &pb.Response{Msg: "Hello " + req.Name}
|
||||
return nil
|
||||
}
|
||||
*/
|
||||
|
||||
func (g *testServer) Call(ctx context.Context, req *pb.Request, rsp *pb.Response) error {
|
||||
if req.Name == "Error" {
|
||||
return &pberr.Error{Id: "id", Code: 99, Detail: "detail"}
|
||||
}
|
||||
rsp.Msg = "Hello " + req.Name
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestGRPCServer(t *testing.T) {
|
||||
var err error
|
||||
|
||||
r := rmemory.NewRegistry()
|
||||
b := bmemory.NewBroker(broker.Registry(r))
|
||||
s := gserver.NewServer(server.Address(":12345"), server.Registry(r), server.Name("helloworld"), gserver.Reflection(true))
|
||||
// create router
|
||||
rtr := regRouter.NewRouter(router.Registry(r))
|
||||
|
||||
h := &testServer{}
|
||||
err = pb.RegisterTestHandler(s, h)
|
||||
if err != nil {
|
||||
t.Fatalf("can't register handler: %v", err)
|
||||
}
|
||||
|
||||
if err = s.Init(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err = s.Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err = s.Stop(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
||||
// create client
|
||||
c := gclient.NewClient(client.Router(rtr), client.Registry(r), client.Broker(b))
|
||||
|
||||
testMethods := []string{
|
||||
"Test.Call",
|
||||
}
|
||||
|
||||
for _, method := range testMethods {
|
||||
req := c.NewRequest("helloworld", method, &pb.Request{
|
||||
Name: "John",
|
||||
})
|
||||
|
||||
rsp := pb.Response{}
|
||||
|
||||
err = c.Call(context.TODO(), req, &rsp)
|
||||
if err != nil {
|
||||
t.Fatalf("method: %s err: %v", method, err)
|
||||
}
|
||||
|
||||
if rsp.Msg != "Hello John" {
|
||||
t.Fatalf("Got unexpected response %v", rsp.Msg)
|
||||
}
|
||||
}
|
||||
|
||||
//rsp := rpb.ServerReflectionResponse{}
|
||||
//req := c.NewRequest("helloworld", "Test.ServerReflectionInfo", &rpb.ServerReflectionRequest{}, client.StreamingRequest())
|
||||
//if err := c.Call(context.TODO(), req, &rsp); err != nil {
|
||||
// t.Fatal(err)
|
||||
//}
|
||||
|
||||
// select {}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user