Adding support to publish on custom host port ranges
Signed-off-by: Don Kjer <don.kjer@gmail.com> Changing vendor/src/github.com/docker/libnetwork to match lindenlab/libnetwork custom-host-port-ranges-1.7 branch
This commit is contained in:
parent
1c1d0c5f6f
commit
e22508c702
3 changed files with 102 additions and 7 deletions
|
@ -41,6 +41,56 @@ func TestParsePort(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestParsePortRange(t *testing.T) {
|
||||
var (
|
||||
begin int
|
||||
end int
|
||||
err error
|
||||
)
|
||||
|
||||
type TestRange struct {
|
||||
Range string
|
||||
Begin int
|
||||
End int
|
||||
}
|
||||
validRanges := []TestRange{
|
||||
{"1234", 1234, 1234},
|
||||
{"1234-1234", 1234, 1234},
|
||||
{"1234-1235", 1234, 1235},
|
||||
{"8000-9000", 8000, 9000},
|
||||
{"0", 0, 0},
|
||||
{"0-0", 0, 0},
|
||||
}
|
||||
|
||||
for _, r := range validRanges {
|
||||
begin, end, err = ParsePortRange(r.Range)
|
||||
|
||||
if err != nil || begin != r.Begin {
|
||||
t.Fatalf("Parsing port range '%s' did not succeed. Expected begin %d, got %d", r.Range, r.Begin, begin)
|
||||
}
|
||||
if err != nil || end != r.End {
|
||||
t.Fatalf("Parsing port range '%s' did not succeed. Expected end %d, got %d", r.Range, r.End, end)
|
||||
}
|
||||
}
|
||||
|
||||
invalidRanges := []string{
|
||||
"asdf",
|
||||
"1asdf",
|
||||
"9000-8000",
|
||||
"9000-",
|
||||
"-8000",
|
||||
"-8000-",
|
||||
}
|
||||
|
||||
for _, r := range invalidRanges {
|
||||
begin, end, err = ParsePortRange(r)
|
||||
|
||||
if err == nil || begin != 0 || end != 0 {
|
||||
t.Fatalf("Parsing port range '%s' succeeded", r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPort(t *testing.T) {
|
||||
p, err := NewPort("tcp", "1234")
|
||||
|
||||
|
@ -68,6 +118,20 @@ func TestPort(t *testing.T) {
|
|||
if err == nil {
|
||||
t.Fatal("tcp, asd1234 was supposed to fail")
|
||||
}
|
||||
|
||||
p, err = NewPort("tcp", "1234-1230")
|
||||
if err == nil {
|
||||
t.Fatal("tcp, 1234-1230 was supposed to fail")
|
||||
}
|
||||
|
||||
p, err = NewPort("tcp", "1234-1242")
|
||||
if err != nil {
|
||||
t.Fatalf("tcp, 1234-1242 had a parsing issue: %v", err)
|
||||
}
|
||||
|
||||
if string(p) != "1234-1242/tcp" {
|
||||
t.Fatal("tcp, 1234-1242 did not result in the string 1234-1242/tcp")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitProtoPort(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue