1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package internal
- import (
- "testing"
- "github.com/stretchr/testify/assert"
- "github.com/wuntsong-org/go-zero-plus/core/discov"
- "github.com/wuntsong-org/go-zero-plus/core/netx"
- )
- func TestNewRpcPubServer(t *testing.T) {
- s, err := NewRpcPubServer(discov.EtcdConf{
- User: "user",
- Pass: "pass",
- ID: 10,
- }, "", ServerMiddlewaresConf{})
- assert.NoError(t, err)
- assert.NotPanics(t, func() {
- s.Start(nil)
- })
- }
- func TestFigureOutListenOn(t *testing.T) {
- tests := []struct {
- input string
- expect string
- }{
- {
- input: "192.168.0.5:1234",
- expect: "192.168.0.5:1234",
- },
- {
- input: "0.0.0.0:8080",
- expect: netx.InternalIp() + ":8080",
- },
- {
- input: ":8080",
- expect: netx.InternalIp() + ":8080",
- },
- {
- input: "",
- expect: netx.InternalIp(),
- },
- }
- for _, test := range tests {
- val := figureOutListenOn(test.input)
- assert.Equal(t, test.expect, val)
- }
- }
|