Put mock registry address in insecureRegistries for unit tests
Signed-off-by: Tibor Vass <teabee89@gmail.com>
This commit is contained in:
parent
80255ff224
commit
cca910e878
2 changed files with 10 additions and 4 deletions
|
@ -20,6 +20,7 @@ import (
|
|||
|
||||
var (
|
||||
testHTTPServer *httptest.Server
|
||||
insecureRegistries []string
|
||||
testLayers = map[string]map[string]string{
|
||||
"77dbf71da1d00e3fbddc480176eac8994025630c6590d11cfc8fe1209c2a1d20": {
|
||||
"json": `{"id":"77dbf71da1d00e3fbddc480176eac8994025630c6590d11cfc8fe1209c2a1d20",
|
||||
|
@ -100,6 +101,11 @@ func init() {
|
|||
r.HandleFunc("/v2/version", handlerGetPing).Methods("GET")
|
||||
|
||||
testHTTPServer = httptest.NewServer(handlerAccessLog(r))
|
||||
URL, err := url.Parse(testHTTPServer.URL)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
insecureRegistries = []string{URL.Host}
|
||||
}
|
||||
|
||||
func handlerAccessLog(handler http.Handler) http.Handler {
|
||||
|
|
|
@ -21,7 +21,7 @@ const (
|
|||
|
||||
func spawnTestRegistrySession(t *testing.T) *Session {
|
||||
authConfig := &AuthConfig{}
|
||||
endpoint, err := NewEndpoint(makeURL("/v1/"), false)
|
||||
endpoint, err := NewEndpoint(makeURL("/v1/"), insecureRegistries)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ func spawnTestRegistrySession(t *testing.T) *Session {
|
|||
}
|
||||
|
||||
func TestPingRegistryEndpoint(t *testing.T) {
|
||||
ep, err := NewEndpoint(makeURL("/v1/"), false)
|
||||
ep, err := NewEndpoint(makeURL("/v1/"), insecureRegistries)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue