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.

38 lines
531 B

  1. package common
  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. "mydomain:80",
  19. "tcp",
  20. "mydomain:80",
  21. },
  22. {
  23. "unix://mydomain:80",
  24. "unix",
  25. "mydomain:80",
  26. },
  27. }
  28. for _, c := range cases {
  29. proto, addr := ProtocolAndAddress(c.fullAddr)
  30. assert.Equal(t, proto, c.proto)
  31. assert.Equal(t, addr, c.addr)
  32. }
  33. }