mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 01:30:25 +08:00
34 lines
551 B
Go
34 lines
551 B
Go
package internal
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/tal-tech/go-zero/core/netx"
|
|
)
|
|
|
|
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",
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
val := figureOutListenOn(test.input)
|
|
assert.Equal(t, test.expect, val)
|
|
}
|
|
}
|