github.com/adxhyt/docker@v1.4.2-0.20150117221845-467b7c821390/registry/endpoint_test.go (about)

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