Add test case IDs
This commit is contained in:
parent
fb10a7ac5a
commit
6058ef137f
7 changed files with 30 additions and 30 deletions
|
@ -100,7 +100,7 @@ func TestBucketViewHandler(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for tcID, tc := range tests {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
r.
|
r.
|
||||||
Methods(http.MethodGet).
|
Methods(http.MethodGet).
|
||||||
|
@ -112,13 +112,13 @@ func TestBucketViewHandler(t *testing.T) {
|
||||||
|
|
||||||
url := fmt.Sprintf("%s/buckets/%s", ts.URL, tc.bucketName)
|
url := fmt.Sprintf("%s/buckets/%s", ts.URL, tc.bucketName)
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
assert.NoError(err)
|
assert.NoError(err, tcID)
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
assert.NoError(err)
|
assert.NoError(err, tcID)
|
||||||
|
|
||||||
assert.Equal(tc.expectedStatusCode, resp.StatusCode)
|
assert.Equal(tc.expectedStatusCode, resp.StatusCode, tcID)
|
||||||
assert.Contains(string(body), tc.expectedBodyCountains)
|
assert.Contains(string(body), tc.expectedBodyCountains, tcID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
req, err := http.NewRequest(http.MethodGet, "/buckets", nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err, tcID)
|
||||||
|
|
||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
handler := BucketsViewHandler(tc.s3)
|
handler := BucketsViewHandler(tc.s3)
|
||||||
|
|
||||||
handler.ServeHTTP(rr, req)
|
handler.ServeHTTP(rr, req)
|
||||||
|
|
||||||
assert.Equal(tc.expectedStatusCode, rr.Code)
|
assert.Equal(tc.expectedStatusCode, rr.Code, tcID)
|
||||||
assert.Contains(rr.Body.String(), tc.expectedBodyContains)
|
assert.Contains(rr.Body.String(), tc.expectedBodyContains, tcID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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))
|
req, err := http.NewRequest(http.MethodPost, "/api/buckets", bytes.NewBufferString(tc.body))
|
||||||
assert.NoError(err)
|
assert.NoError(err, tcID)
|
||||||
|
|
||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
handler := CreateBucketHandler(tc.s3)
|
handler := CreateBucketHandler(tc.s3)
|
||||||
|
|
||||||
handler.ServeHTTP(rr, req)
|
handler.ServeHTTP(rr, req)
|
||||||
|
|
||||||
assert.Equal(tc.expectedStatusCode, rr.Code)
|
assert.Equal(tc.expectedStatusCode, rr.Code, tcID)
|
||||||
assert.Equal(tc.expectedBody, rr.Body.String())
|
assert.Equal(tc.expectedBody, rr.Body.String(), tcID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
req, err := http.NewRequest(http.MethodDelete, "/api/buckets/bucketName", nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err, tcID)
|
||||||
|
|
||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
handler := DeleteBucketHandler(tc.s3)
|
handler := DeleteBucketHandler(tc.s3)
|
||||||
|
|
||||||
handler.ServeHTTP(rr, req)
|
handler.ServeHTTP(rr, req)
|
||||||
|
|
||||||
assert.Equal(tc.expectedStatusCode, rr.Code)
|
assert.Equal(tc.expectedStatusCode, rr.Code, tcID)
|
||||||
assert.Equal(tc.expectedBody, rr.Body.String())
|
assert.Equal(tc.expectedBody, rr.Body.String(), tcID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
req, err := http.NewRequest(http.MethodDelete, "/api/buckets/bucketName/objects/objectName", nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err, tcID)
|
||||||
|
|
||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
handler := DeleteObjectHandler(tc.s3)
|
handler := DeleteObjectHandler(tc.s3)
|
||||||
|
|
||||||
handler.ServeHTTP(rr, req)
|
handler.ServeHTTP(rr, req)
|
||||||
|
|
||||||
assert.Equal(tc.expectedStatusCode, rr.Code)
|
assert.Equal(tc.expectedStatusCode, rr.Code, tcID)
|
||||||
assert.Equal(tc.expectedBody, rr.Body.String())
|
assert.Equal(tc.expectedBody, rr.Body.String(), tcID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ func TestGetObjectHandler(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for tcID, tc := range tests {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
r.
|
r.
|
||||||
Methods(http.MethodGet).
|
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)
|
url := fmt.Sprintf("%s/buckets/%s/objects/%s", ts.URL, tc.bucketName, tc.objectName)
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
assert.NoError(err)
|
assert.NoError(err, tcID)
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
assert.NoError(err)
|
assert.NoError(err, tcID)
|
||||||
|
|
||||||
assert.Equal(tc.expectedStatusCode, resp.StatusCode)
|
assert.Equal(tc.expectedStatusCode, resp.StatusCode, tcID)
|
||||||
assert.Contains(string(body), tc.expectedBodyCountains)
|
assert.Contains(string(body), tc.expectedBodyCountains, tcID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
req, err := http.NewRequest(http.MethodGet, "/", nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err, tcID)
|
||||||
|
|
||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
handler := IndexViewHandler()
|
handler := IndexViewHandler()
|
||||||
|
|
||||||
handler.ServeHTTP(rr, req)
|
handler.ServeHTTP(rr, req)
|
||||||
|
|
||||||
assert.Equal(tc.expectedStatusCode, rr.Code)
|
assert.Equal(tc.expectedStatusCode, rr.Code, tcID)
|
||||||
assert.Contains(rr.Body.String(), tc.expectedBodyContains)
|
assert.Contains(rr.Body.String(), tc.expectedBodyContains, tcID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue