1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
//go:build linux
package bridge
import (
"net"
"testing"
"github.com/docker/docker/libnetwork/types"
)
func getPorts() []types.TransportPort {
return []types.TransportPort{
{Proto: types.TCP, Port: uint16(5000)},
{Proto: types.UDP, Port: uint16(400)},
{Proto: types.TCP, Port: uint16(600)},
}
}
func TestLinkNew(t *testing.T) {
ports := getPorts()
const (
pIP = "172.0.17.3"
cIP = "172.0.17.2"
bridgeName = "docker0"
)
parentIP := net.ParseIP(pIP)
childIP := net.ParseIP(cIP)
l, err := newLink(parentIP, childIP, ports, bridgeName)
if err != nil {
t.Errorf("unexpected error from newlink(): %v", err)
}
if l == nil {
t.FailNow()
}
if l.parentIP.String() != pIP {
t.Fail()
}
if l.childIP.String() != cIP {
t.Fail()
}
for i, p := range l.ports {
if p != ports[i] {
t.Fail()
}
}
if l.bridge != bridgeName {
t.Fail()
}
}
|