improve tests

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-11-05 22:38:29 +03:00
parent c9255752a0
commit f484976f55
3 changed files with 37 additions and 8 deletions

18
go.mod
View File

@ -8,15 +8,19 @@ require (
github.com/opentracing/opentracing-go v1.2.0
github.com/stretchr/testify v1.5.1
github.com/unistack-org/micro-broker-http v0.0.0-20201102230515-e1a6d448f88f
github.com/unistack-org/micro-broker-memory v0.0.2-0.20201016070326-b0839e582a1f
github.com/unistack-org/micro-broker-memory v0.0.2-0.20201105185131-5ff932308afd
github.com/unistack-org/micro-client-grpc v0.0.2-0.20201028070730-15a5d7d2cde8
github.com/unistack-org/micro-registry-memory v0.0.2-0.20201102230949-e1dbabb9e52e
github.com/unistack-org/micro-router-registry v0.0.2-0.20201102231321-9d3c8475fb6e
github.com/unistack-org/micro-server-grpc v0.0.2-0.20201102231531-46ed1f8fa484
github.com/unistack-org/micro-server-http v0.0.2-0.20201102230653-860a1929f4e7
github.com/unistack-org/micro-server-tcp v0.0.2-0.20201102231432-4585a4fb9a68
github.com/unistack-org/micro-registry-memory v0.0.2-0.20201105183335-7e2d2ae89e38
github.com/unistack-org/micro-router-registry v0.0.2-0.20201105175056-773128885d9e
github.com/unistack-org/micro-server-grpc v0.0.2-0.20201104230137-31c35661ae73
github.com/unistack-org/micro-server-http v0.0.2-0.20201104225538-7d3dc63ae435
github.com/unistack-org/micro-server-tcp v0.0.2-0.20201104231236-b12d45f45cbc
github.com/unistack-org/micro-wrapper-opentracing v0.0.1
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20201102230232-8a2b12201568
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20201105193505-8fa8afdfa4b4
google.golang.org/grpc v1.31.1
google.golang.org/protobuf v1.25.0
)
replace github.com/unistack-org/micro/v3 => ../micro
replace github.com/unistack-org/micro-registry-memory => ../done/micro-registry-memory

12
go.sum
View File

@ -267,6 +267,8 @@ github.com/unistack-org/micro-broker-http v0.0.0-20201102230515-e1a6d448f88f h1:
github.com/unistack-org/micro-broker-http v0.0.0-20201102230515-e1a6d448f88f/go.mod h1:d2NYj/cl/7WBPk5K6Ef3By8Pj2ZN41mFn3LfZFLHYfA=
github.com/unistack-org/micro-broker-memory v0.0.2-0.20201016070326-b0839e582a1f h1:493n3a+jy+UOZh+aGoaCrdVJI/MEreZzcAPVE+TN5VM=
github.com/unistack-org/micro-broker-memory v0.0.2-0.20201016070326-b0839e582a1f/go.mod h1:DvqNKOik/6Tfbv8wVkxv76ozArlwC8yXZbKXTQlnANo=
github.com/unistack-org/micro-broker-memory v0.0.2-0.20201105185131-5ff932308afd h1:LNMB1G3yZEI1zpX4SGodLqUfOw4Zan30rcpcvKTDMCI=
github.com/unistack-org/micro-broker-memory v0.0.2-0.20201105185131-5ff932308afd/go.mod h1:BlX+zLHGZxNngsiGiAaIqt0XjwIk3iurw4cqRFYRaVk=
github.com/unistack-org/micro-client-grpc v0.0.2-0.20201028070730-15a5d7d2cde8 h1:ozSg+KCknYKVYrRAH4j1kssc2TBJhuvrxl6z3xXmXsQ=
github.com/unistack-org/micro-client-grpc v0.0.2-0.20201028070730-15a5d7d2cde8/go.mod h1:VQQ0HUGgk1IWrtTUetEV7UMuy2KWsLX5GV3UWUZBpQQ=
github.com/unistack-org/micro-codec-bytes v0.0.0-20200827104921-3616a69473a6/go.mod h1:g5sOI8TWgGZiVHe8zoUPdtz7+0oLnqTnfBoai6Qb7jE=
@ -288,14 +290,24 @@ github.com/unistack-org/micro-config-cmd v0.0.0-20201028144621-5a55f1aad70a h1:V
github.com/unistack-org/micro-config-cmd v0.0.0-20201028144621-5a55f1aad70a/go.mod h1:MzMg+qh1wORZwYtg5AVgFkNFrXVVbdPKW7s/Is+A994=
github.com/unistack-org/micro-registry-memory v0.0.2-0.20201102230949-e1dbabb9e52e h1:BY+O5KAKZvhiuNbuWB7bEZh1jLXtYrcgZqaVD6eJDu8=
github.com/unistack-org/micro-registry-memory v0.0.2-0.20201102230949-e1dbabb9e52e/go.mod h1:aIM3yJ5hwWXP9XQfDcykAKffpyiM7N55nIFu26rtfIk=
github.com/unistack-org/micro-registry-memory v0.0.2-0.20201105183335-7e2d2ae89e38 h1:mEmyX5PQDHIUUDWG3Z+jhlR0L6S8cyDeLzHhl6AdMJk=
github.com/unistack-org/micro-registry-memory v0.0.2-0.20201105183335-7e2d2ae89e38/go.mod h1:/tk793OnoBSCM7m2nYA4rW0vUdQjP6ASc22BVt6S7Y0=
github.com/unistack-org/micro-router-registry v0.0.2-0.20201102231321-9d3c8475fb6e h1:VpYSUBhUOxOdm3Jpxb2AK9K8ACYn+V2z7QBKnyJMmfE=
github.com/unistack-org/micro-router-registry v0.0.2-0.20201102231321-9d3c8475fb6e/go.mod h1:gtXDLAjrRjx2Ydc/LvtYkXOFEljqmol65PSVITcST98=
github.com/unistack-org/micro-router-registry v0.0.2-0.20201105175056-773128885d9e h1:spzPFROFgxXCoggEv0dapiH3Hfp0x/HqQy4rimQ1rbU=
github.com/unistack-org/micro-router-registry v0.0.2-0.20201105175056-773128885d9e/go.mod h1:nvJqRLixa2UqbctfnMx1WJ6IJdPJQ9FheJnh+03QsXA=
github.com/unistack-org/micro-server-grpc v0.0.2-0.20201102231531-46ed1f8fa484 h1:Tn2mowUM/I6auvBNXC9h9ZVljE/9XeDu4ohl9zR7wtM=
github.com/unistack-org/micro-server-grpc v0.0.2-0.20201102231531-46ed1f8fa484/go.mod h1:jijuX1asaRpWzcqnMqaQIACOHmuh0U2NcHda4gGpDWo=
github.com/unistack-org/micro-server-grpc v0.0.2-0.20201104230137-31c35661ae73 h1:12YaMyj2b+P9MO9QJ2zu2fjtcASFK7pD3O/dyp55iUQ=
github.com/unistack-org/micro-server-grpc v0.0.2-0.20201104230137-31c35661ae73/go.mod h1:EzFbU2AkFyDTlCIn4biNtOgLF/rMgxDp72ezWvMl8Is=
github.com/unistack-org/micro-server-http v0.0.2-0.20201102230653-860a1929f4e7 h1:/Z2f0AMJ2lfTksnLFmxaj8Kke7FWug+S0MBnPtaKesY=
github.com/unistack-org/micro-server-http v0.0.2-0.20201102230653-860a1929f4e7/go.mod h1:kveJd2rfdccJQxyJabJvY8txtBi6ttPUdkdHEkko7X0=
github.com/unistack-org/micro-server-http v0.0.2-0.20201104225538-7d3dc63ae435 h1:a6c4WEBNqxTaTOX0+cPtJsIZbb5iAu8BphwoGcGhMaA=
github.com/unistack-org/micro-server-http v0.0.2-0.20201104225538-7d3dc63ae435/go.mod h1:hlRr6JKzG6dswJYiEWT71nCwxqfpR+dK7FVJCZ+RjNE=
github.com/unistack-org/micro-server-tcp v0.0.2-0.20201102231432-4585a4fb9a68 h1:h+BNBBR12+xIsAYYAOx4JxQXFxaOgGxAptmqSKCP49s=
github.com/unistack-org/micro-server-tcp v0.0.2-0.20201102231432-4585a4fb9a68/go.mod h1:dJDyKGh6Uq8eoDRmhZDSWcMx9eRCOB9YTrnXPi5QlPc=
github.com/unistack-org/micro-server-tcp v0.0.2-0.20201104231236-b12d45f45cbc h1:RYSaZEEEbtvE55wqLWPjkZ7MoGS99t8QfQNcBXt8uiM=
github.com/unistack-org/micro-server-tcp v0.0.2-0.20201104231236-b12d45f45cbc/go.mod h1:81eVN8JwO92fZtcBYeWz5aFE8Pe0RhReRu1x3uhhCkI=
github.com/unistack-org/micro-wrapper-opentracing v0.0.1 h1:GOyN4CMbtJxEW8knB9DrRbgyaCtwOxqFtNqr2FVwoMk=
github.com/unistack-org/micro-wrapper-opentracing v0.0.1/go.mod h1:cSUWWr/frBBcKV4f5VRSN9dsFv6PWRV3rPaa6ULnZCw=
github.com/unistack-org/micro/v3 v3.0.0-20200827083227-aa99378adc6e/go.mod h1:rPQbnry3nboAnMczj8B1Gzlcyv/HYoMZLgd3/3nttJ4=

View File

@ -22,8 +22,17 @@ type testHandler struct {
func TestTCPServer(t *testing.T) {
ctx := context.Background()
logger.DefaultLogger = logger.NewLogger(logger.WithLevel(logger.TraceLevel))
reg := rmemory.NewRegistry()
if err := reg.Init(); err != nil {
t.Fatal(err)
}
brk := bmemory.NewBroker(broker.Registry(reg))
if err := brk.Init(); err != nil {
t.Fatal(err)
}
// create server
srv := tcp.NewServer(server.Registry(reg), server.Broker(brk), server.Address("127.0.0.1:65000"))
@ -35,6 +44,10 @@ func TestTCPServer(t *testing.T) {
t.Fatal(err)
}
if err := srv.Init(); err != nil {
t.Fatal(err)
}
// start server
if err := srv.Start(); err != nil {
t.Fatal(err)
@ -86,7 +99,7 @@ func (h *testHandler) Serve(c net.Conn) {
if err != nil && err == io.EOF {
return
} else if err != nil {
logger.Fatal(err)
logger.Fatal(err.Error())
}
fmt.Printf("%s", buf[:n])
close(h.done)