2018-02-05 21:05:59 +00:00
|
|
|
package registry // import "github.com/docker/docker/registry"
|
2016-11-05 22:53:11 +00:00
|
|
|
|
2018-04-20 09:59:08 +00:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2018-06-11 13:32:11 +00:00
|
|
|
"gotest.tools/skip"
|
2018-04-20 09:59:08 +00:00
|
|
|
)
|
2016-11-05 22:53:11 +00:00
|
|
|
|
|
|
|
func TestLookupV1Endpoints(t *testing.T) {
|
2018-04-20 09:59:08 +00:00
|
|
|
skip.If(t, os.Getuid() != 0, "skipping test that requires root")
|
2017-09-01 14:35:04 +00:00
|
|
|
s, err := NewService(ServiceOptions{})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2016-11-05 22:53:11 +00:00
|
|
|
|
|
|
|
cases := []struct {
|
|
|
|
hostname string
|
|
|
|
expectedLen int
|
|
|
|
}{
|
|
|
|
{"example.com", 1},
|
|
|
|
{DefaultNamespace, 0},
|
|
|
|
{DefaultV2Registry.Host, 0},
|
|
|
|
{IndexHostname, 0},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, c := range cases {
|
|
|
|
if ret, err := s.lookupV1Endpoints(c.hostname); err != nil || len(ret) != c.expectedLen {
|
|
|
|
t.Errorf("lookupV1Endpoints(`"+c.hostname+"`) returned %+v and %+v", ret, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|