endpoint_test.go 616 B

123456789101112131415161718192021222324252627
  1. package registry
  2. import "testing"
  3. func TestEndpointParse(t *testing.T) {
  4. testData := []struct {
  5. str string
  6. expected string
  7. }{
  8. {IndexServerAddress(), IndexServerAddress()},
  9. {"http://0.0.0.0:5000", "http://0.0.0.0:5000/v1/"},
  10. {"0.0.0.0:5000", "https://0.0.0.0:5000/v1/"},
  11. }
  12. for _, td := range testData {
  13. e, err := newEndpoint(td.str, false)
  14. if err != nil {
  15. t.Errorf("%q: %s", td.str, err)
  16. }
  17. if e == nil {
  18. t.Logf("something's fishy, endpoint for %q is nil", td.str)
  19. continue
  20. }
  21. if e.String() != td.expected {
  22. t.Errorf("expected %q, got %q", td.expected, e.String())
  23. }
  24. }
  25. }