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