mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
3ecd8ff0c8
This facilitates the refactoring of commands.go Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
41 lines
716 B
Go
41 lines
716 B
Go
package nat
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestSortUniquePorts(t *testing.T) {
|
|
ports := []Port{
|
|
Port("6379/tcp"),
|
|
Port("22/tcp"),
|
|
}
|
|
|
|
Sort(ports, func(ip, jp Port) bool {
|
|
return ip.Int() < jp.Int() || (ip.Int() == jp.Int() && ip.Proto() == "tcp")
|
|
})
|
|
|
|
first := ports[0]
|
|
if fmt.Sprint(first) != "22/tcp" {
|
|
t.Log(fmt.Sprint(first))
|
|
t.Fail()
|
|
}
|
|
}
|
|
|
|
func TestSortSamePortWithDifferentProto(t *testing.T) {
|
|
ports := []Port{
|
|
Port("8888/tcp"),
|
|
Port("8888/udp"),
|
|
Port("6379/tcp"),
|
|
Port("6379/udp"),
|
|
}
|
|
|
|
Sort(ports, func(ip, jp Port) bool {
|
|
return ip.Int() < jp.Int() || (ip.Int() == jp.Int() && ip.Proto() == "tcp")
|
|
})
|
|
|
|
first := ports[0]
|
|
if fmt.Sprint(first) != "6379/tcp" {
|
|
t.Fail()
|
|
}
|
|
}
|