mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
added test, gofmtd
Signed-off-by: shuai-z <zs.broccoli@gmail.com>
This commit is contained in:
parent
9451cf39ef
commit
2c2edabca5
2 changed files with 17 additions and 1 deletions
|
@ -14,7 +14,7 @@ type portMap struct {
|
|||
|
||||
func newPortMap() *portMap {
|
||||
return &portMap{
|
||||
p: map[int]struct{}{},
|
||||
p: map[int]struct{}{},
|
||||
last: EndPortRange,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,3 +214,19 @@ func TestPortAllocation(t *testing.T) {
|
|||
t.Fatal("Requesting a dynamic port should never allocate a used port")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoDuplicateBPR(t *testing.T) {
|
||||
defer reset()
|
||||
|
||||
if port, err := RequestPort(defaultIP, "tcp", BeginPortRange); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if port != BeginPortRange {
|
||||
t.Fatalf("Expected port %d got %d", BeginPortRange, port)
|
||||
}
|
||||
|
||||
if port, err := RequestPort(defaultIP, "tcp", 0); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if port == BeginPortRange {
|
||||
t.Fatalf("Acquire(0) allocated the same port twice: %d", port)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue