Mock registry: Fixed a bug where the index validation path would return a 200 status code instead of the expected 204

This commit is contained in:
shin- 2013-07-31 19:05:06 +02:00
parent 04cbff8d35
commit 93877a859a

View file

@ -11,6 +11,7 @@ import (
"net/http/httptest" "net/http/httptest"
"net/url" "net/url"
"strconv" "strconv"
"strings"
"testing" "testing"
"time" "time"
) )
@ -291,7 +292,12 @@ func handlerUsers(w http.ResponseWriter, r *http.Request) {
func handlerImages(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", u.Host) w.Header().Add("X-Docker-Endpoints", u.Host)
w.Header().Add("X-Docker-Token", fmt.Sprintf("FAKE-SESSION-%d", time.Now().UnixNano()))
if r.Method == "PUT" { if r.Method == "PUT" {
if strings.HasSuffix(r.URL.Path, "images") {
writeResponse(w, "", 204)
return
}
writeResponse(w, "", 200) writeResponse(w, "", 200)
return return
} }
@ -330,6 +336,7 @@ func TestPing(t *testing.T) {
/* Uncomment this to test Mocked Registry locally with curl /* Uncomment this to test Mocked Registry locally with curl
* WARNING: Don't push on the repos uncommented, it'll block the tests * WARNING: Don't push on the repos uncommented, it'll block the tests
<<<<<<< HEAD
* *
func TestWait(t *testing.T) { func TestWait(t *testing.T) {
log.Println("Test HTTP server ready and waiting:", testHttpServer.URL) log.Println("Test HTTP server ready and waiting:", testHttpServer.URL)
@ -338,3 +345,11 @@ func TestWait(t *testing.T) {
} }
//*/ //*/
=======
*/
// func TestWait(t *testing.T) {
// log.Println("Test HTTP server ready and waiting:", testHttpServer.URL)
// c := make(chan int)
// <-c
// }
>>>>>>> Mock registry: Fixed a bug where the index validation path would return a 200 status code instead of the expected 204