diff --git a/bucket-view_test.go b/bucket-view_test.go index e3e00f7..2a63196 100644 --- a/bucket-view_test.go +++ b/bucket-view_test.go @@ -113,7 +113,10 @@ func TestBucketViewHandler(t *testing.T) { url := fmt.Sprintf("%s/buckets/%s", ts.URL, tc.bucketName) resp, err := http.Get(url) assert.NoError(err, tcID) - defer resp.Body.Close() + defer func() { + err = resp.Body.Close() + assert.NoError(err, tcID) + }() body, err := ioutil.ReadAll(resp.Body) assert.NoError(err, tcID) diff --git a/create-object.go b/create-object.go index 61be02e..3fb89ae 100644 --- a/create-object.go +++ b/create-object.go @@ -3,6 +3,7 @@ package main import ( "encoding/json" "fmt" + "log" "net/http" "github.com/gorilla/mux" @@ -63,7 +64,12 @@ func CreateObjectFromFormHandler(s3 S3Client) http.Handler { handleHTTPError(w, http.StatusInternalServerError, err) return } - defer file.Close() + defer func() { + err = file.Close() + if err != nil { + log.Fatalln(err) + } + }() _, err = s3.PutObject(vars["bucketName"], handler.Filename, file, contentTypeOctetStream) if err != nil { diff --git a/get-object_test.go b/get-object_test.go index 1ed9ffe..f928bc5 100644 --- a/get-object_test.go +++ b/get-object_test.go @@ -46,7 +46,10 @@ func TestGetObjectHandler(t *testing.T) { url := fmt.Sprintf("%s/buckets/%s/objects/%s", ts.URL, tc.bucketName, tc.objectName) resp, err := http.Get(url) assert.NoError(err, tcID) - defer resp.Body.Close() + defer func() { + err = resp.Body.Close() + assert.NoError(err, tcID) + }() body, err := ioutil.ReadAll(resp.Body) assert.NoError(err, tcID) diff --git a/s3-client-mock.go b/s3-client-mock.go index e96929d..b7400c1 100644 --- a/s3-client-mock.go +++ b/s3-client-mock.go @@ -34,7 +34,7 @@ func (s S3ClientMock) ListBuckets() ([]minio.BucketInfo, error) { } // ListObjectsV2 mocks minio.Client.ListObjectsV2 -func (s S3ClientMock) ListObjectsV2(bucketName string, p string, r bool, d <-chan struct{}) <-chan minio.ObjectInfo { +func (s S3ClientMock) ListObjectsV2(name string, p string, r bool, d <-chan struct{}) <-chan minio.ObjectInfo { // Add error if exists if s.Err != nil { s.Objects = append(s.Objects, minio.ObjectInfo{ @@ -45,7 +45,7 @@ func (s S3ClientMock) ListObjectsV2(bucketName string, p string, r bool, d <-cha // Check if bucket exists found := false for _, b := range s.Buckets { - if b.Name == bucketName { + if b.Name == name { found = true break } diff --git a/templates/layout.html.tmpl b/templates/layout.html.tmpl index acd6af5..363cbb8 100644 --- a/templates/layout.html.tmpl +++ b/templates/layout.html.tmpl @@ -10,7 +10,7 @@