github.com/lingyao2333/mo-zero@v1.4.1/zrpc/internal/rpcpubserver_test.go (about) 1 package internal 2 3 import ( 4 "testing" 5 6 "github.com/lingyao2333/mo-zero/core/netx" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestFigureOutListenOn(t *testing.T) { 11 tests := []struct { 12 input string 13 expect string 14 }{ 15 { 16 input: "192.168.0.5:1234", 17 expect: "192.168.0.5:1234", 18 }, 19 { 20 input: "0.0.0.0:8080", 21 expect: netx.InternalIp() + ":8080", 22 }, 23 { 24 input: ":8080", 25 expect: netx.InternalIp() + ":8080", 26 }, 27 } 28 29 for _, test := range tests { 30 val := figureOutListenOn(test.input) 31 assert.Equal(t, test.expect, val) 32 } 33 }