From dc47ca14311a35aff18375521f08dd9f7585afed Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 1 Feb 2015 17:21:12 -0800 Subject: [PATCH] Fix build issue --- pkg/api/minioapi/minioapi.go | 12 ++++++++---- pkg/api/minioapi/minioapi_test.go | 5 +---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/api/minioapi/minioapi.go b/pkg/api/minioapi/minioapi.go index 8389e61be..364bfd495 100644 --- a/pkg/api/minioapi/minioapi.go +++ b/pkg/api/minioapi/minioapi.go @@ -127,13 +127,17 @@ func (server *minioApi) putBucketHandler(w http.ResponseWriter, req *http.Reques vars := mux.Vars(req) bucket := vars["bucket"] err := server.storage.StoreBucket(bucket) - if err != nil { + switch err := err.(type) { + case nil: + w.Header().Set("Server", "Minio") + w.Header().Set("Connection", "close") + case mstorage.BucketNameInvalid: w.WriteHeader(http.StatusBadRequest) w.Write([]byte(err.Error())) - return + case mstorage.BucketExists: + w.WriteHeader(http.StatusConflict) + w.Write([]byte(err.Error())) } - w.Header().Set("Server", "Minio") - w.Header().Set("Connection", "close") } func (server *minioApi) getObjectHandler(w http.ResponseWriter, req *http.Request) { diff --git a/pkg/api/minioapi/minioapi_test.go b/pkg/api/minioapi/minioapi_test.go index 6ad82efa8..aa96ad751 100644 --- a/pkg/api/minioapi/minioapi_test.go +++ b/pkg/api/minioapi/minioapi_test.go @@ -241,13 +241,10 @@ func (s *MySuite) TestPutObject(c *C) { testServer := httptest.NewServer(httpHandler) defer testServer.Close() - err := storage.StoreBucket("bucket") - c.Assert(err, IsNil) - objects, isTruncated, err := storage.ListObjects("bucket", "", 1000) c.Assert(len(objects), Equals, 0) c.Assert(isTruncated, Equals, false) - c.Assert(err, IsNil) + c.Assert(err, Not(IsNil)) date1 := time.Now()