From ae3afae89326fcb42e053ddb77fb6b1110158796 Mon Sep 17 00:00:00 2001 From: Lena Fuhrimann <6780471+cloudlena@users.noreply.github.com> Date: Wed, 19 Apr 2017 14:18:58 +0200 Subject: [PATCH] Update dependencies --- bucket-view_test.go | 5 ++++- create-object.go | 8 +++++++- get-object_test.go | 5 ++++- s3-client-mock.go | 4 ++-- templates/layout.html.tmpl | 4 ++-- 5 files changed, 19 insertions(+), 7 deletions(-) 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 @@ S3 Manager - + @@ -18,7 +18,7 @@ {{ template "content" . }} - +