forked from TrueCloudLab/distribution
Put mock registry address in insecureRegistries for unit tests
Signed-off-by: Tibor Vass <teabee89@gmail.com> Conflicts: registry/registry_mock_test.go
This commit is contained in:
parent
44d97c1fd0
commit
8b0e8b6621
2 changed files with 13 additions and 7 deletions
|
@ -19,8 +19,9 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
testHttpServer *httptest.Server
|
||||
testLayers = map[string]map[string]string{
|
||||
testHTTPServer *httptest.Server
|
||||
insecureRegistries []string
|
||||
testLayers = map[string]map[string]string{
|
||||
"77dbf71da1d00e3fbddc480176eac8994025630c6590d11cfc8fe1209c2a1d20": {
|
||||
"json": `{"id":"77dbf71da1d00e3fbddc480176eac8994025630c6590d11cfc8fe1209c2a1d20",
|
||||
"comment":"test base image","created":"2013-03-23T12:53:11.10432-07:00",
|
||||
|
@ -99,7 +100,12 @@ func init() {
|
|||
// /v2/
|
||||
r.HandleFunc("/v2/version", handlerGetPing).Methods("GET")
|
||||
|
||||
testHttpServer = httptest.NewServer(handlerAccessLog(r))
|
||||
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 {
|
||||
|
@ -111,7 +117,7 @@ func handlerAccessLog(handler http.Handler) http.Handler {
|
|||
}
|
||||
|
||||
func makeURL(req string) string {
|
||||
return testHttpServer.URL + req
|
||||
return testHTTPServer.URL + req
|
||||
}
|
||||
|
||||
func writeHeaders(w http.ResponseWriter) {
|
||||
|
@ -301,7 +307,7 @@ func handlerUsers(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func handlerImages(w http.ResponseWriter, r *http.Request) {
|
||||
u, _ := url.Parse(testHttpServer.URL)
|
||||
u, _ := url.Parse(testHTTPServer.URL)
|
||||
w.Header().Add("X-Docker-Endpoints", fmt.Sprintf("%s , %s ", u.Host, "test.example.com"))
|
||||
w.Header().Add("X-Docker-Token", fmt.Sprintf("FAKE-SESSION-%d", time.Now().UnixNano()))
|
||||
if r.Method == "PUT" {
|
||||
|
|
|
@ -18,7 +18,7 @@ var (
|
|||
|
||||
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)
|
||||
}
|
||||
|
@ -30,7 +30,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