update tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
ba7d0703a3
commit
0cde3df915
@ -26,6 +26,7 @@ import (
|
||||
"github.com/unistack-org/micro/v3/api/router"
|
||||
"github.com/unistack-org/micro/v3/broker"
|
||||
"github.com/unistack-org/micro/v3/client"
|
||||
"github.com/unistack-org/micro/v3/errors"
|
||||
"github.com/unistack-org/micro/v3/register"
|
||||
rt "github.com/unistack-org/micro/v3/router"
|
||||
"github.com/unistack-org/micro/v3/server"
|
||||
@ -124,9 +125,16 @@ func check(t *testing.T, addr string, path string, expected string, timeout bool
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
jsonMsg := expected
|
||||
if string(buf) != jsonMsg {
|
||||
t.Fatalf("invalid message received, parsing error %s != %s", buf, jsonMsg)
|
||||
reterr := errors.Parse(string(buf))
|
||||
experr := errors.Parse(expected)
|
||||
if reterr.Code != 0 || experr.Code != 0 {
|
||||
if !errors.Equal(reterr, experr) {
|
||||
t.Fatalf("invalid message received, parsing error %s != %s", buf, expected)
|
||||
}
|
||||
} else {
|
||||
if string(buf) != expected {
|
||||
t.Fatalf("invalid message received, parsing error %s != %s", buf, expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
2
go.mod
2
go.mod
@ -30,7 +30,7 @@ require (
|
||||
github.com/unistack-org/micro-server-http/v3 v3.2.9
|
||||
github.com/unistack-org/micro-server-tcp/v3 v3.2.2
|
||||
github.com/unistack-org/micro-wrapper-trace-opentracing/v3 v3.2.0
|
||||
github.com/unistack-org/micro/v3 v3.2.17
|
||||
github.com/unistack-org/micro/v3 v3.2.18
|
||||
google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb
|
||||
google.golang.org/grpc v1.36.0
|
||||
google.golang.org/protobuf v1.25.1-0.20201208041424-160c7477e0e8
|
||||
|
25
go.sum
25
go.sum
@ -463,8 +463,7 @@ github.com/unistack-org/micro-codec-segmentio/v3 v3.1.1 h1:WFVNcXNm58bEOKnubTztB
|
||||
github.com/unistack-org/micro-codec-segmentio/v3 v3.1.1/go.mod h1:FSrl+q83cohF2N7CmIdi36D6bZsjfGKMhhw0WaozlLs=
|
||||
github.com/unistack-org/micro-config-env/v3 v3.2.4 h1:mMle6VvwmhabvohRxGfNxhcOeVUenLq2mR1goXpLJys=
|
||||
github.com/unistack-org/micro-config-env/v3 v3.2.4/go.mod h1:NzhRyDsCgNzRhEtuVathSToOIzmkHCEICiSNZsVN75U=
|
||||
github.com/unistack-org/micro-config-vault/v3 v3.2.4 h1:HUOsVbQoki8YdISUVk3jzTgKYVJSxkLsjGG2Hcu8rhk=
|
||||
github.com/unistack-org/micro-config-vault/v3 v3.2.4/go.mod h1:Xbj5R5psic0Dyuh7SrJqvFv0hSIHYKHx91p96rn/lxk=
|
||||
github.com/unistack-org/micro-config-vault/v3 v3.2.7 h1:ShEoXpBgXBdZeVsnnVGE0GidD/BGjqpaL9xe6BJ5oQc=
|
||||
github.com/unistack-org/micro-config-vault/v3 v3.2.7/go.mod h1:bGiA3wWJRfn+uvaLczzaGqlWeWRBmMDKBzo+x3ESxP4=
|
||||
github.com/unistack-org/micro-metrics-prometheus/v3 v3.1.1 h1:AZVQ8l1p1pIUyImQo/if/5t1g9C9du9ulMRqATSmgGo=
|
||||
github.com/unistack-org/micro-metrics-prometheus/v3 v3.1.1/go.mod h1:QfquVeYZ2+BqBQ5bv1+uFAeWFiacvwanRDy3nGVqo3c=
|
||||
@ -472,13 +471,8 @@ github.com/unistack-org/micro-proto v0.0.2-0.20210227213711-77c7563bd01e h1:hQJ3
|
||||
github.com/unistack-org/micro-proto v0.0.2-0.20210227213711-77c7563bd01e/go.mod h1:GYO53DWmeldRIo90cAdQx8bLr/WJMxW62W4ja74p1Ac=
|
||||
github.com/unistack-org/micro-router-register/v3 v3.2.2 h1:lYCymDHkJfhZWYQ4+Sb7Fu+NlqoysQCnpJytHGhdnws=
|
||||
github.com/unistack-org/micro-router-register/v3 v3.2.2/go.mod h1:Y9Qtlg4NHqq5rR6X6Jm+04LoSJMi7/OOCm2mRueZYTE=
|
||||
github.com/unistack-org/micro-server-grpc/v3 v3.2.3 h1:Q6zBB4ipgI6yptC0b7jyXULuRQ4s7sLfSmEbUWYOBUQ=
|
||||
github.com/unistack-org/micro-server-grpc/v3 v3.2.3/go.mod h1:rSb800jZW5x4sKV1mX6HdYtp7fXSrnCdqCJ6C5+Fb/Y=
|
||||
github.com/unistack-org/micro-server-grpc/v3 v3.2.4 h1:C/vkzkZ0rpzLIYiaIK53kk5KIfBox2JCbqLvMwz0lWI=
|
||||
github.com/unistack-org/micro-server-grpc/v3 v3.2.4/go.mod h1:ZtCwgb0E7vS4C9GBqpLCNpyQs8TrHQSh4Q0RuNiWE7Y=
|
||||
github.com/unistack-org/micro-server-http/v3 v3.2.6 h1:Ykd4M6cqH5gVq06XgOuHb1Tc/RPHku7Kc+UsrjN90Jc=
|
||||
github.com/unistack-org/micro-server-http/v3 v3.2.6/go.mod h1:EEtAuq3F7eNQYdeANzQpz2Y9YYNrQxopKyMP+7xxb7s=
|
||||
github.com/unistack-org/micro-server-http/v3 v3.2.8 h1:r1bz4Ti3cCO9T7+OYjsAbSyC5/ub6sWlzIKPclRuIs4=
|
||||
github.com/unistack-org/micro-server-http/v3 v3.2.8/go.mod h1:UhKAFn/RhM8EJ3YNSwWI6mpfMcEBbtW8b+26JOFihoA=
|
||||
github.com/unistack-org/micro-server-http/v3 v3.2.9 h1:m5od6wCmx58Vzmbrhm+uYNNpN3AGT+RXdzf4cAszPTc=
|
||||
github.com/unistack-org/micro-server-http/v3 v3.2.9/go.mod h1:TUIksrJUzTnH13Qs4skgEyADvMLK/3JgzjJ4Sx/yxN4=
|
||||
github.com/unistack-org/micro-server-tcp/v3 v3.2.2 h1:2/Xn+4+dnzY/tpD3MgLO1wg3ect9Jx5CLSDfPBjdjT4=
|
||||
@ -491,14 +485,10 @@ github.com/unistack-org/micro/v3 v3.2.2/go.mod h1:J8XxJj4Pqa3Ee0a4biRRtut7UwTlfB
|
||||
github.com/unistack-org/micro/v3 v3.2.4/go.mod h1:J8XxJj4Pqa3Ee0a4biRRtut7UwTlfBq8QRe+s4PKGS0=
|
||||
github.com/unistack-org/micro/v3 v3.2.11/go.mod h1:uGPB8BhDWHj63tR3eaoCd3X+lPtAgFG630897yhB3Ag=
|
||||
github.com/unistack-org/micro/v3 v3.2.14/go.mod h1:3j13mSd/rILNjyP0tEVtDxyDkJBtnHUXShNCuPHkC5A=
|
||||
github.com/unistack-org/micro/v3 v3.2.15-0.20210221215218-09973af099cd h1:r5Ii2dGYhLn0JzyQntmm1Y6LZ1Snr1iAHjexvZx+ETg=
|
||||
github.com/unistack-org/micro/v3 v3.2.15-0.20210221215218-09973af099cd/go.mod h1:ydfsnbOiNtKTSCx6SzYyPXntdK31FyhbsDrOvrGw4oM=
|
||||
github.com/unistack-org/micro/v3 v3.2.15 h1:9Wg6FAFVPUijAm5ZFF+y4oYEd8zd/Pp48QwmMrSs074=
|
||||
github.com/unistack-org/micro/v3 v3.2.15/go.mod h1:y+fV+BPNK2IqGoLquRU396jTYifG0HCw3zxFfI4E0dc=
|
||||
github.com/unistack-org/micro/v3 v3.2.16 h1:eQwEJr7RiB0jvOSAil+c6t2C1zW7MpfFAVx2u9PmItM=
|
||||
github.com/unistack-org/micro/v3 v3.2.16/go.mod h1:y+fV+BPNK2IqGoLquRU396jTYifG0HCw3zxFfI4E0dc=
|
||||
github.com/unistack-org/micro/v3 v3.2.17 h1:WNkkcKj1NMLViH9YgSDJRA2PJxIaDmY3GQBjHQV20DU=
|
||||
github.com/unistack-org/micro/v3 v3.2.17/go.mod h1:y+fV+BPNK2IqGoLquRU396jTYifG0HCw3zxFfI4E0dc=
|
||||
github.com/unistack-org/micro/v3 v3.2.18 h1:+EnZ6xJJzHINQr7c8nkwygkfy+qLssiKd1hktgEzHL4=
|
||||
github.com/unistack-org/micro/v3 v3.2.18/go.mod h1:y+fV+BPNK2IqGoLquRU396jTYifG0HCw3zxFfI4E0dc=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/vultr/govultr v0.1.4/go.mod h1:9H008Uxr/C4vFNGLqKx232C206GL0PBHzOP0809bGNA=
|
||||
@ -583,9 +573,6 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
|
||||
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7 h1:OgUuv8lsRpBibGNbSizVwKWlysjaNzmC9gYMhPVfqFM=
|
||||
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@ -698,10 +685,6 @@ google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBr
|
||||
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-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705 h1:PYBmACG+YEv8uQPW0r1kJj8tR+gkF0UWq7iFdUezwEw=
|
||||
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210302174412-5ede27ff9881 h1:SYuy3hIRsBIROE0aZwsJZOEJNC/n9/p0FmLEU9C31AE=
|
||||
google.golang.org/genproto v0.0.0-20210302174412-5ede27ff9881/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb h1:hcskBH5qZCOa7WpTUFUFvoebnSFZBYpjykLtjIp9DVk=
|
||||
google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||||
|
@ -48,7 +48,7 @@ func TestGRPCServer(t *testing.T) {
|
||||
|
||||
r := register.NewRegister()
|
||||
b := broker.NewBroker(broker.Register(r))
|
||||
s := gserver.NewServer(server.Codec("application/grpc+proto", protocodec.NewCodec()), server.Address(":12345"), server.Register(r), server.Name("helloworld"), gserver.Reflection(true),
|
||||
s := gserver.NewServer(server.Codec("application/grpc+proto", protocodec.NewCodec()), server.Address(":0"), server.Register(r), server.Name("helloworld"), gserver.Reflection(true),
|
||||
server.WrapHandler(NewServerHandlerWrapper()),
|
||||
)
|
||||
// create router
|
||||
|
@ -51,6 +51,9 @@ func (h *Handler) Call(ctx context.Context, req *pb.CallReq, rsp *pb.CallRsp) er
|
||||
}
|
||||
rsp.Rsp = "name_my_name"
|
||||
httpsrv.SetRspCode(ctx, http.StatusCreated)
|
||||
md = metadata.New(1)
|
||||
md.Set("my-key", "my-val")
|
||||
metadata.SetOutgoingContext(ctx, md)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -185,6 +188,10 @@ func TestNativeServer(t *testing.T) {
|
||||
t.Fatalf("Expected response %s, got %s", `{"rsp":"name_my_name"}`, s)
|
||||
}
|
||||
|
||||
if v := rsp.Header.Get("My-Key"); v != "my-val" {
|
||||
t.Fatalf("empty response header: %#+v", rsp.Header)
|
||||
}
|
||||
|
||||
// make request with error
|
||||
rsp, err = http.Post(fmt.Sprintf("http://%s/v1/test/callerror/my_name", service[0].Nodes[0].Address), "application/json", nil)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user