2018-02-05 16:05:59 -05:00
|
|
|
package registry // import "github.com/docker/docker/registry"
|
2016-11-05 18:53:11 -04:00
|
|
|
|
2018-04-20 05:59:08 -04:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2018-06-11 09:32:11 -04:00
|
|
|
"gotest.tools/skip"
|
2018-04-20 05:59:08 -04:00
|
|
|
)
|
2016-11-05 18:53:11 -04:00
|
|
|
|
|
|
|
func TestLookupV1Endpoints(t *testing.T) {
|
2018-04-20 05:59:08 -04:00
|
|
|
skip.If(t, os.Getuid() != 0, "skipping test that requires root")
|
2017-09-01 10:35:04 -04:00
|
|
|
s, err := NewService(ServiceOptions{})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2016-11-05 18:53:11 -04: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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|