mirror of
https://github.com/minio/minio.git
synced 2024-12-28 08:05:55 -05:00
Merge pull request #435 from fkautz/pr_out_adding_iodine_and_tests_for_for_list_buckets_errors
This commit is contained in:
commit
a6fc618f91
@ -105,14 +105,9 @@ func (server *minioAPI) listBucketsHandler(w http.ResponseWriter, req *http.Requ
|
||||
encodedResponse := encodeResponse(response, acceptsContentType)
|
||||
w.Write(encodedResponse)
|
||||
}
|
||||
case drivers.BackendCorrupted:
|
||||
{
|
||||
log.Error.Println(err)
|
||||
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path)
|
||||
}
|
||||
default:
|
||||
{
|
||||
log.Error.Println(err)
|
||||
log.Error.Println(iodine.New(err, nil))
|
||||
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path)
|
||||
}
|
||||
}
|
||||
|
@ -894,19 +894,9 @@ func (s *MySuite) TestPartialContent(c *C) {
|
||||
}
|
||||
|
||||
func (s *MySuite) TestListObjectsHandlerErrors(c *C) {
|
||||
switch driver := s.Driver.(type) {
|
||||
case *mocks.Driver:
|
||||
{
|
||||
driver.AssertExpectations(c)
|
||||
}
|
||||
default:
|
||||
{
|
||||
// We mock failures here to test
|
||||
return
|
||||
}
|
||||
}
|
||||
driver := s.Driver
|
||||
typedDriver := s.MockDriver
|
||||
driver := startMockDriver()
|
||||
typedDriver := driver
|
||||
defer driver.AssertExpectations(c)
|
||||
|
||||
httpHandler := api.HTTPHandler("", driver)
|
||||
testServer := httptest.NewServer(httpHandler)
|
||||
@ -942,6 +932,24 @@ func (s *MySuite) TestListObjectsHandlerErrors(c *C) {
|
||||
verifyError(c, response, "InternalError", "We encountered an internal error, please try again.", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
func (s *MySuite) TestListBucketsErrors(c *C) {
|
||||
driver := startMockDriver()
|
||||
typedDriver := driver
|
||||
defer driver.AssertExpectations(c)
|
||||
|
||||
httpHandler := api.HTTPHandler("", driver)
|
||||
testServer := httptest.NewServer(httpHandler)
|
||||
defer testServer.Close()
|
||||
client := http.Client{}
|
||||
|
||||
typedDriver.On("ListObjects", "foo", mock.Anything).Return(make([]drivers.ObjectMetadata, 0), drivers.BucketResourcesMetadata{}, drivers.BackendCorrupted{}).Once()
|
||||
request, err := http.NewRequest("GET", testServer.URL+"/foo", bytes.NewBufferString(""))
|
||||
c.Assert(err, IsNil)
|
||||
response, err := client.Do(request)
|
||||
c.Assert(err, IsNil)
|
||||
verifyError(c, response, "InternalError", "We encountered an internal error, please try again.", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
func verifyError(c *C, response *http.Response, code, description string, statusCode int) {
|
||||
data, err := ioutil.ReadAll(response.Body)
|
||||
c.Assert(err, IsNil)
|
||||
|
Loading…
Reference in New Issue
Block a user