Adding iodine and tests for for list buckets errors
This commit is contained in:
parent
37c601c21c
commit
ebf1e784b3
|
@ -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 a new issue