github.com/zhouyu0/docker-note@v0.0.0-20190722021225-b8d3825084db/registry/service_v1_test.go (about) 1 package registry // import "github.com/docker/docker/registry" 2 3 import ( 4 "os" 5 "testing" 6 7 "gotest.tools/skip" 8 ) 9 10 func TestLookupV1Endpoints(t *testing.T) { 11 skip.If(t, os.Getuid() != 0, "skipping test that requires root") 12 s, err := NewService(ServiceOptions{}) 13 if err != nil { 14 t.Fatal(err) 15 } 16 17 cases := []struct { 18 hostname string 19 expectedLen int 20 }{ 21 {"example.com", 1}, 22 {DefaultNamespace, 0}, 23 {DefaultV2Registry.Host, 0}, 24 {IndexHostname, 0}, 25 } 26 27 for _, c := range cases { 28 if ret, err := s.lookupV1Endpoints(c.hostname); err != nil || len(ret) != c.expectedLen { 29 t.Errorf("lookupV1Endpoints(`"+c.hostname+"`) returned %+v and %+v", ret, err) 30 } 31 } 32 }