Files
cms-server/data/drivers/postgres_test.go
Asai Neko 210b8b08ce
All checks were successful
Server Check Build (NixCN CMS) TeamCity build finished
Add test for all components
Signed-off-by: Asai Neko <sugar@sne.moe>
2026-03-26 18:19:26 +08:00

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)
}