chore: add more tests (#2814)
This commit is contained in:
@@ -4,9 +4,21 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/zeromicro/go-zero/core/discov"
|
||||||
"github.com/zeromicro/go-zero/core/netx"
|
"github.com/zeromicro/go-zero/core/netx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestNewRpcPubServer(t *testing.T) {
|
||||||
|
s, err := NewRpcPubServer(discov.EtcdConf{
|
||||||
|
User: "user",
|
||||||
|
Pass: "pass",
|
||||||
|
}, "", ServerMiddlewaresConf{})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.NotPanics(t, func() {
|
||||||
|
s.Start(nil)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestFigureOutListenOn(t *testing.T) {
|
func TestFigureOutListenOn(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
input string
|
input string
|
||||||
@@ -24,6 +36,10 @@ func TestFigureOutListenOn(t *testing.T) {
|
|||||||
input: ":8080",
|
input: ":8080",
|
||||||
expect: netx.InternalIp() + ":8080",
|
expect: netx.InternalIp() + ":8080",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: "",
|
||||||
|
expect: netx.InternalIp(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func TestRpcServer(t *testing.T) {
|
|||||||
Stat: true,
|
Stat: true,
|
||||||
Prometheus: true,
|
Prometheus: true,
|
||||||
Breaker: true,
|
Breaker: true,
|
||||||
}, WithMetrics(metrics))
|
}, WithMetrics(metrics), WithRpcHealth(true))
|
||||||
server.SetName("mock")
|
server.SetName("mock")
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var grpcServer *grpc.Server
|
var grpcServer *grpc.Server
|
||||||
@@ -48,7 +48,7 @@ func TestRpcServer_WithBadAddress(t *testing.T) {
|
|||||||
Stat: true,
|
Stat: true,
|
||||||
Prometheus: true,
|
Prometheus: true,
|
||||||
Breaker: true,
|
Breaker: true,
|
||||||
})
|
}, WithRpcHealth(true))
|
||||||
server.SetName("mock")
|
server.SetName("mock")
|
||||||
err := server.Start(func(server *grpc.Server) {
|
err := server.Start(func(server *grpc.Server) {
|
||||||
mock.RegisterDepositServiceServer(server, new(mock.DepositServer))
|
mock.RegisterDepositServiceServer(server, new(mock.DepositServer))
|
||||||
|
|||||||
Reference in New Issue
Block a user