diff --git a/Makefile b/Makefile index 294311b0..5198a4b4 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ checkgopath: @for mcpath in $(echo ${GOPATH} | sed 's/:/\n/g' | grep -v Godeps); do if [ ! -d ${mcpath}/src/github.com/minio/mc ]; then echo "Project not found in ${mcpath}, please follow instructions provided at https://github.com/minio/minio/blob/master/CONTRIBUTING.md#setup-your-minio-github-repository" && exit 1; fi done getdeps: checkdeps checkgopath - @go get github.com/minio/godep && echo "Installed godep:" + @go get github.com/tools/godep && echo "Installed godep:" @go get github.com/golang/lint/golint && echo "Installed golint:" @go get golang.org/x/tools/cmd/vet && echo "Installed vet:" @go get github.com/fzipp/gocyclo && echo "Installed gocyclo:" diff --git a/api_handlers_test.go b/api_handlers_test.go index e3bd479d..e386db3a 100644 --- a/api_handlers_test.go +++ b/api_handlers_test.go @@ -22,15 +22,19 @@ import ( "net/http" "path/filepath" "strconv" + "sync" "time" ) type objectAPIHandler struct { + lock *sync.Mutex bucket string object map[string][]byte } func (h objectAPIHandler) getHandler(w http.ResponseWriter, r *http.Request) { + h.lock.Lock() + defer h.lock.Unlock() switch { case r.URL.Path == "/": response := []byte("bucket2015-05-20T23:05:09.230Zminiominio") @@ -53,6 +57,8 @@ func (h objectAPIHandler) getHandler(w http.ResponseWriter, r *http.Request) { } func (h objectAPIHandler) headHandler(w http.ResponseWriter, r *http.Request) { + h.lock.Lock() + defer h.lock.Unlock() switch { case r.URL.Path == "/": w.WriteHeader(http.StatusOK) @@ -70,6 +76,8 @@ func (h objectAPIHandler) headHandler(w http.ResponseWriter, r *http.Request) { } func (h objectAPIHandler) putHandler(w http.ResponseWriter, r *http.Request) { + h.lock.Lock() + defer h.lock.Unlock() switch { case r.URL.Path == "/": w.WriteHeader(http.StatusBadRequest) diff --git a/cmd_test.go b/cmd_test.go index c8bc8d43..83e3b4ff 100644 --- a/cmd_test.go +++ b/cmd_test.go @@ -23,6 +23,7 @@ import ( "os" "path/filepath" "runtime" + "sync" "testing" "net/http/httptest" @@ -55,7 +56,7 @@ func (s *CmdTestSuite) SetUpSuite(c *C) { _, err = doConfig("generate", nil) c.Assert(err, IsNil) - objectAPI := objectAPIHandler(objectAPIHandler{bucket: "bucket", object: make(map[string][]byte)}) + objectAPI := objectAPIHandler(objectAPIHandler{lock: &sync.Mutex{}, bucket: "bucket", object: make(map[string][]byte)}) server = httptest.NewServer(objectAPI) }