ceph-csi/vendor/github.com/go-openapi/swag/net_test.go
Serguei Bezverkhi 7b24313bd6 vendor files
2018-01-10 13:42:26 -05:00

31 lines
605 B
Go

package swag
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSplitHostPort(t *testing.T) {
data := []struct {
Input string
Host string
Port int
Err bool
}{
{"localhost:3933", "localhost", 3933, false},
{"localhost:yellow", "", -1, true},
{"localhost", "", -1, true},
{"localhost:", "", -1, true},
{"localhost:3933", "localhost", 3933, false},
}
for _, e := range data {
h, p, err := SplitHostPort(e.Input)
if (!e.Err && assert.NoError(t, err)) || (e.Err && assert.Error(t, err)) {
assert.Equal(t, e.Host, h)
assert.Equal(t, e.Port, p)
}
}
}