cri-o/vendor/github.com/go-openapi/swag/net_test.go
Jacek J. Łakis bf51655a7b vendor: Update vendoring for the exec client and server implementations
Signed-off-by: Jacek J. Łakis <jacek.lakis@intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2017-04-24 18:38:41 +02:00

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