You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
591 B

  1. package net
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestProtocolAndAddress(t *testing.T) {
  7. cases := []struct {
  8. fullAddr string
  9. proto string
  10. addr string
  11. }{
  12. {
  13. "tcp://mydomain:80",
  14. "tcp",
  15. "mydomain:80",
  16. },
  17. {
  18. "grpc://mydomain:80",
  19. "grpc",
  20. "mydomain:80",
  21. },
  22. {
  23. "mydomain:80",
  24. "tcp",
  25. "mydomain:80",
  26. },
  27. {
  28. "unix://mydomain:80",
  29. "unix",
  30. "mydomain:80",
  31. },
  32. }
  33. for _, c := range cases {
  34. proto, addr := ProtocolAndAddress(c.fullAddr)
  35. assert.Equal(t, proto, c.proto)
  36. assert.Equal(t, addr, c.addr)
  37. }
  38. }