Files
EdgeCommon/pkg/serverconfigs/server_address_group_test.go

35 lines
770 B
Go
Raw Normal View History

2020-09-13 19:27:47 +08:00
package serverconfigs
import (
"github.com/iwind/TeaGo/assert"
"testing"
)
2021-09-22 19:39:55 +08:00
func TestServerAddressGroup_Protocol(t *testing.T) {
2020-09-13 19:27:47 +08:00
a := assert.NewAssertion(t)
{
2021-09-22 19:39:55 +08:00
group := NewServerAddressGroup("tcp://127.0.0.1:1234")
2020-09-13 19:27:47 +08:00
a.IsTrue(group.Protocol() == ProtocolTCP)
a.IsTrue(group.Addr() == "127.0.0.1:1234")
}
{
2021-09-22 19:39:55 +08:00
group := NewServerAddressGroup("http4://127.0.0.1:1234")
2020-09-13 19:27:47 +08:00
a.IsTrue(group.Protocol() == ProtocolHTTP4)
a.IsTrue(group.Addr() == "127.0.0.1:1234")
}
{
2021-09-22 19:39:55 +08:00
group := NewServerAddressGroup("127.0.0.1:1234")
2020-09-13 19:27:47 +08:00
a.IsTrue(group.Protocol() == ProtocolHTTP)
a.IsTrue(group.Addr() == "127.0.0.1:1234")
}
{
2021-09-22 19:39:55 +08:00
group := NewServerAddressGroup("unix:/tmp/my.sock")
2020-09-13 19:27:47 +08:00
a.IsTrue(group.Protocol() == ProtocolUnix)
a.IsTrue(group.Addr() == "/tmp/my.sock")
}
}