All checks were successful
Server Check Build (NixCN CMS) TeamCity build finished
Signed-off-by: Asai Neko <sugar@sne.moe>
32 lines
708 B
Go
32 lines
708 B
Go
package drivers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestSplitHostPortWithPort(t *testing.T) {
|
|
host, port := SplitHostPort("localhost:5432")
|
|
assert.Equal(t, "localhost", host)
|
|
assert.Equal(t, "5432", port)
|
|
}
|
|
|
|
func TestSplitHostPortWithoutPort(t *testing.T) {
|
|
host, port := SplitHostPort("localhost")
|
|
assert.Equal(t, "localhost", host)
|
|
assert.Equal(t, "5432", port)
|
|
}
|
|
|
|
func TestSplitHostPortIPWithPort(t *testing.T) {
|
|
host, port := SplitHostPort("127.0.0.1:9999")
|
|
assert.Equal(t, "127.0.0.1", host)
|
|
assert.Equal(t, "9999", port)
|
|
}
|
|
|
|
func TestSplitHostPortEmpty(t *testing.T) {
|
|
host, port := SplitHostPort("")
|
|
assert.Equal(t, "", host)
|
|
assert.Equal(t, "5432", port)
|
|
}
|