Răsfoiți Sursa

chore: add more tests (#2814)

Kevin Wan 2 ani în urmă
părinte
comite
ceab564429
2 a modificat fișierele cu 18 adăugiri și 2 ștergeri
  1. 16 0
      zrpc/internal/rpcpubserver_test.go
  2. 2 2
      zrpc/internal/rpcserver_test.go

+ 16 - 0
zrpc/internal/rpcpubserver_test.go

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

+ 2 - 2
zrpc/internal/rpcserver_test.go

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