link_test.go 651 B

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