@@ -89,7 +89,7 @@ func TestHttpRespToErrorResponse(t *testing.T) {
8989 genInvalidError := func (message string ) error {
9090 errResp := ErrorResponse {
9191 StatusCode : http .StatusBadRequest ,
92- Code : " InvalidArgument" ,
92+ Code : InvalidArgument ,
9393 Message : message ,
9494 RequestID : "minio" ,
9595 }
@@ -134,7 +134,7 @@ func TestHttpRespToErrorResponse(t *testing.T) {
134134 // List of APIErrors used to generate/mock server side XML error response.
135135 APIErrors := []APIError {
136136 {
137- Code : " NoSuchBucketPolicy" ,
137+ Code : NoSuchBucketPolicy ,
138138 Description : "The specified bucket does not have a bucket policy." ,
139139 HTTPStatusCode : http .StatusNotFound ,
140140 },
@@ -145,10 +145,10 @@ func TestHttpRespToErrorResponse(t *testing.T) {
145145 expectedErrResponse := []error {
146146 genInvalidError ("Empty http response. " + "Please report this issue at https://github.com/minio/minio-go/issues." ),
147147 decodeXMLError (createAPIErrorResponse (APIErrors [0 ], "minio-bucket" )),
148- genErrResponse (setCommonHeaders (& http.Response {StatusCode : http .StatusNotFound }), " NoSuchBucket" , "The specified bucket does not exist." , "minio-bucket" , "" ),
149- genErrResponse (setCommonHeaders (& http.Response {StatusCode : http .StatusNotFound }), " NoSuchKey" , "The specified key does not exist." , "minio-bucket" , "Asia/" ),
150- genErrResponse (setCommonHeaders (& http.Response {StatusCode : http .StatusForbidden }), " AccessDenied" , "Access Denied." , "minio-bucket" , "" ),
151- genErrResponse (setCommonHeaders (& http.Response {StatusCode : http .StatusConflict }), " Conflict" , "Bucket not empty." , "minio-bucket" , "" ),
148+ genErrResponse (setCommonHeaders (& http.Response {StatusCode : http .StatusNotFound }), NoSuchBucket , s3ErrorResponseMap [ NoSuchBucket ] , "minio-bucket" , "" ),
149+ genErrResponse (setCommonHeaders (& http.Response {StatusCode : http .StatusNotFound }), NoSuchKey , s3ErrorResponseMap [ NoSuchKey ] , "minio-bucket" , "Asia/" ),
150+ genErrResponse (setCommonHeaders (& http.Response {StatusCode : http .StatusForbidden }), AccessDenied , s3ErrorResponseMap [ AccessDenied ] , "minio-bucket" , "" ),
151+ genErrResponse (setCommonHeaders (& http.Response {StatusCode : http .StatusConflict }), Conflict , s3ErrorResponseMap [ Conflict ] , "minio-bucket" , "" ),
152152 genErrResponse (setCommonHeaders (& http.Response {StatusCode : http .StatusBadRequest }), "Bad Request" , "Bad Request" , "minio-bucket" , "" ),
153153 genErrResponse (setCommonHeaders (& http.Response {StatusCode : http .StatusInternalServerError }), "Internal Server Error" , "my custom object store error" , "minio-bucket" , "" ),
154154 genErrResponse (setCommonHeaders (& http.Response {StatusCode : http .StatusInternalServerError }), "Internal Server Error" , "my custom object store error, with way too long body" , "minio-bucket" , "" ),
@@ -199,7 +199,7 @@ func TestErrEntityTooLarge(t *testing.T) {
199199 msg := fmt .Sprintf ("Your proposed upload size ‘%d’ exceeds the maximum allowed object size ‘%d’ for single PUT operation." , 1000000 , 99999 )
200200 expectedResult := ErrorResponse {
201201 StatusCode : http .StatusBadRequest ,
202- Code : " EntityTooLarge" ,
202+ Code : EntityTooLarge ,
203203 Message : msg ,
204204 BucketName : "minio-bucket" ,
205205 Key : "Asia/" ,
@@ -215,7 +215,7 @@ func TestErrEntityTooSmall(t *testing.T) {
215215 msg := fmt .Sprintf ("Your proposed upload size ‘%d’ is below the minimum allowed object size ‘0B’ for single PUT operation." , - 1 )
216216 expectedResult := ErrorResponse {
217217 StatusCode : http .StatusBadRequest ,
218- Code : " EntityTooSmall" ,
218+ Code : EntityTooSmall ,
219219 Message : msg ,
220220 BucketName : "minio-bucket" ,
221221 Key : "Asia/" ,
@@ -232,7 +232,7 @@ func TestErrUnexpectedEOF(t *testing.T) {
232232 strconv .FormatInt (100 , 10 ), strconv .FormatInt (101 , 10 ))
233233 expectedResult := ErrorResponse {
234234 StatusCode : http .StatusBadRequest ,
235- Code : " UnexpectedEOF" ,
235+ Code : UnexpectedEOF ,
236236 Message : msg ,
237237 BucketName : "minio-bucket" ,
238238 Key : "Asia/" ,
@@ -247,7 +247,7 @@ func TestErrUnexpectedEOF(t *testing.T) {
247247func TestErrInvalidArgument (t * testing.T ) {
248248 expectedResult := ErrorResponse {
249249 StatusCode : http .StatusBadRequest ,
250- Code : " InvalidArgument" ,
250+ Code : InvalidArgument ,
251251 Message : "Invalid Argument" ,
252252 RequestID : "minio" ,
253253 }
@@ -260,20 +260,20 @@ func TestErrInvalidArgument(t *testing.T) {
260260// Tests if the Message field is missing.
261261func TestErrWithoutMessage (t * testing.T ) {
262262 errResp := ErrorResponse {
263- Code : " AccessDenied" ,
263+ Code : AccessDenied ,
264264 RequestID : "minio" ,
265265 }
266266
267- if errResp .Error () != "Access Denied." {
268- t .Errorf ("Expected \" Access Denied. \" , got %s" , errResp )
267+ if errResp .Error () != s3ErrorResponseMap [ AccessDenied ] {
268+ t .Errorf ("Expected \" %s \" , got %s" , s3ErrorResponseMap [ AccessDenied ] , errResp )
269269 }
270270
271271 errResp = ErrorResponse {
272- Code : " InvalidArgument" ,
272+ Code : InvalidArgument ,
273273 RequestID : "minio" ,
274274 }
275275 if errResp .Error () != fmt .Sprintf ("Error response code %s." , errResp .Code ) {
276- t .Errorf ("Expected \" Error response code InvalidArgument .\" , got \" %s\" " , errResp )
276+ t .Errorf ("Expected \" Error response code %s .\" , got \" %s\" " , InvalidArgument , errResp )
277277 }
278278}
279279
0 commit comments