Add test case IDs

This commit is contained in:
Lena Fuhrimann 2017-04-07 12:51:23 +02:00
parent fb10a7ac5a
commit 6058ef137f
7 changed files with 30 additions and 30 deletions

View file

@ -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)
}
}

View file

@ -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)
}
}

View file

@ -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)
}
}

View file

@ -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)
}
}

View file

@ -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)
}
}

View file

@ -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)
}
}

View file

@ -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)
}
}