link_test.go 675 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // +build linux
  2. package bridge
  3. import (
  4. "testing"
  5. "github.com/docker/docker/libnetwork/types"
  6. )
  7. func getPorts() []types.TransportPort {
  8. return []types.TransportPort{
  9. {Proto: types.TCP, Port: uint16(5000)},
  10. {Proto: types.UDP, Port: uint16(400)},
  11. {Proto: types.TCP, Port: uint16(600)},
  12. }
  13. }
  14. func TestLinkNew(t *testing.T) {
  15. ports := getPorts()
  16. link := newLink("172.0.17.3", "172.0.17.2", ports, "docker0")
  17. if link == nil {
  18. t.FailNow()
  19. }
  20. if link.parentIP != "172.0.17.3" {
  21. t.Fail()
  22. }
  23. if link.childIP != "172.0.17.2" {
  24. t.Fail()
  25. }
  26. for i, p := range link.ports {
  27. if p != ports[i] {
  28. t.Fail()
  29. }
  30. }
  31. if link.bridge != "docker0" {
  32. t.Fail()
  33. }
  34. }