chore: add more tests (#2814)

This commit is contained in:
Kevin Wan
2023-01-24 12:03:05 +08:00
committed by GitHub
parent 4bd8025c5b
commit ceab564429
2 changed files with 18 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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))