From 6058ef137f566dc5dd70c3e1d05ce982a291d8c5 Mon Sep 17 00:00:00 2001 From: Lena Fuhrimann <6780471+cloudlena@users.noreply.github.com> Date: Fri, 7 Apr 2017 12:51:23 +0200 Subject: [PATCH] Add test case IDs --- bucket-view_test.go | 10 +++++----- buckets-view_test.go | 8 ++++---- create-bucket_test.go | 8 ++++---- delete-bucket_test.go | 8 ++++---- delete-object_test.go | 8 ++++---- get-object_test.go | 10 +++++----- index-view_test.go | 8 ++++---- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/bucket-view_test.go b/bucket-view_test.go index f738776..8228fc7 100644 --- a/bucket-view_test.go +++ b/bucket-view_test.go @@ -100,7 +100,7 @@ func TestBucketViewHandler(t *testing.T) { }, } - for _, tc := range tests { + for tcID, tc := range tests { r := mux.NewRouter() r. Methods(http.MethodGet). @@ -112,13 +112,13 @@ func TestBucketViewHandler(t *testing.T) { url := fmt.Sprintf("%s/buckets/%s", ts.URL, tc.bucketName) resp, err := http.Get(url) - assert.NoError(err) + assert.NoError(err, tcID) defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) - assert.NoError(err) + assert.NoError(err, tcID) - assert.Equal(tc.expectedStatusCode, resp.StatusCode) - assert.Contains(string(body), tc.expectedBodyCountains) + assert.Equal(tc.expectedStatusCode, resp.StatusCode, tcID) + assert.Contains(string(body), tc.expectedBodyCountains, tcID) } } diff --git a/buckets-view_test.go b/buckets-view_test.go index 6e3f626..080bbaa 100644 --- a/buckets-view_test.go +++ b/buckets-view_test.go @@ -41,16 +41,16 @@ func TestBucketsViewHandler(t *testing.T) { }, } - for _, tc := range tests { + for tcID, tc := range tests { req, err := http.NewRequest(http.MethodGet, "/buckets", nil) - assert.NoError(err) + assert.NoError(err, tcID) rr := httptest.NewRecorder() handler := BucketsViewHandler(tc.s3) handler.ServeHTTP(rr, req) - assert.Equal(tc.expectedStatusCode, rr.Code) - assert.Contains(rr.Body.String(), tc.expectedBodyContains) + assert.Equal(tc.expectedStatusCode, rr.Code, tcID) + assert.Contains(rr.Body.String(), tc.expectedBodyContains, tcID) } } diff --git a/create-bucket_test.go b/create-bucket_test.go index aa1504d..627ef92 100644 --- a/create-bucket_test.go +++ b/create-bucket_test.go @@ -47,16 +47,16 @@ func TestCreateBucketHandler(t *testing.T) { }, } - for _, tc := range tests { + for tcID, tc := range tests { req, err := http.NewRequest(http.MethodPost, "/api/buckets", bytes.NewBufferString(tc.body)) - assert.NoError(err) + assert.NoError(err, tcID) rr := httptest.NewRecorder() handler := CreateBucketHandler(tc.s3) handler.ServeHTTP(rr, req) - assert.Equal(tc.expectedStatusCode, rr.Code) - assert.Equal(tc.expectedBody, rr.Body.String()) + assert.Equal(tc.expectedStatusCode, rr.Code, tcID) + assert.Equal(tc.expectedBody, rr.Body.String(), tcID) } } diff --git a/delete-bucket_test.go b/delete-bucket_test.go index 6e88260..9250b31 100644 --- a/delete-bucket_test.go +++ b/delete-bucket_test.go @@ -31,16 +31,16 @@ func TestDeleteBucketHandler(t *testing.T) { }, } - for _, tc := range tests { + for tcID, tc := range tests { req, err := http.NewRequest(http.MethodDelete, "/api/buckets/bucketName", nil) - assert.NoError(err) + assert.NoError(err, tcID) rr := httptest.NewRecorder() handler := DeleteBucketHandler(tc.s3) handler.ServeHTTP(rr, req) - assert.Equal(tc.expectedStatusCode, rr.Code) - assert.Equal(tc.expectedBody, rr.Body.String()) + assert.Equal(tc.expectedStatusCode, rr.Code, tcID) + assert.Equal(tc.expectedBody, rr.Body.String(), tcID) } } diff --git a/delete-object_test.go b/delete-object_test.go index 9063fa3..26babd8 100644 --- a/delete-object_test.go +++ b/delete-object_test.go @@ -31,16 +31,16 @@ func TestDeleteObjectHandler(t *testing.T) { }, } - for _, tc := range tests { + for tcID, tc := range tests { req, err := http.NewRequest(http.MethodDelete, "/api/buckets/bucketName/objects/objectName", nil) - assert.NoError(err) + assert.NoError(err, tcID) rr := httptest.NewRecorder() handler := DeleteObjectHandler(tc.s3) handler.ServeHTTP(rr, req) - assert.Equal(tc.expectedStatusCode, rr.Code) - assert.Equal(tc.expectedBody, rr.Body.String()) + assert.Equal(tc.expectedStatusCode, rr.Code, tcID) + assert.Equal(tc.expectedBody, rr.Body.String(), tcID) } } diff --git a/get-object_test.go b/get-object_test.go index 5dd06ee..85b018e 100644 --- a/get-object_test.go +++ b/get-object_test.go @@ -33,7 +33,7 @@ func TestGetObjectHandler(t *testing.T) { }, } - for _, tc := range tests { + for tcID, tc := range tests { r := mux.NewRouter() r. Methods(http.MethodGet). @@ -45,13 +45,13 @@ 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) + assert.NoError(err, tcID) defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) - assert.NoError(err) + assert.NoError(err, tcID) - assert.Equal(tc.expectedStatusCode, resp.StatusCode) - assert.Contains(string(body), tc.expectedBodyCountains) + assert.Equal(tc.expectedStatusCode, resp.StatusCode, tcID) + assert.Contains(string(body), tc.expectedBodyCountains, tcID) } } diff --git a/index-view_test.go b/index-view_test.go index b428209..f3f59a6 100644 --- a/index-view_test.go +++ b/index-view_test.go @@ -21,16 +21,16 @@ func TestIndexViewHandler(t *testing.T) { }, } - for _, tc := range tests { + for tcID, tc := range tests { req, err := http.NewRequest(http.MethodGet, "/", nil) - assert.NoError(err) + assert.NoError(err, tcID) rr := httptest.NewRecorder() handler := IndexViewHandler() handler.ServeHTTP(rr, req) - assert.Equal(tc.expectedStatusCode, rr.Code) - assert.Contains(rr.Body.String(), tc.expectedBodyContains) + assert.Equal(tc.expectedStatusCode, rr.Code, tcID) + assert.Contains(rr.Body.String(), tc.expectedBodyContains, tcID) } }