Cover errors in registerAdminArnsHandlers (#2059)

To cover errors in registerAdminArnsHandlers
This commit is contained in:
Cesar Celis Hernandez
2022-05-31 15:42:16 -04:00
committed by GitHub
parent b02e649405
commit d956ec65a2
2 changed files with 24 additions and 1 deletions

View File

@@ -1521,7 +1521,7 @@ jobs:
go tool cover -func=all.out | grep total > tmp2
result=`cat tmp2 | awk 'END {print $3}'`
result=${result%\%}
threshold=50.6
threshold=50.7
echo "Result:"
echo "$result%"
if (( $(echo "$result >= $threshold" |bc -l) )); then

View File

@@ -20,8 +20,14 @@ import (
"context"
"errors"
"fmt"
"net/http"
"strings"
"testing"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/models"
"github.com/minio/console/restapi/operations/system"
"github.com/go-openapi/loads"
"github.com/minio/console/restapi/operations"
"github.com/minio/madmin-go"
@@ -71,4 +77,21 @@ func TestRegisterAdminArnsHandlers(t *testing.T) {
} else {
fmt.Println("Function got assigned: ", api.SystemArnListHandler)
}
// To test error case in registerAdminArnsHandlers
request, _ := http.NewRequest(
"GET",
"http://localhost:9090/api/v1/buckets/",
nil,
)
ArnListParamsStruct := system.ArnListParams{
HTTPRequest: request,
}
modelsPrincipal := models.Principal{
STSAccessKeyID: "accesskey",
}
var value middleware.Responder = api.SystemArnListHandler.Handle(ArnListParamsStruct, &modelsPrincipal)
str := fmt.Sprintf("%#v", value)
fmt.Println("value: ", str)
assert.Equal(strings.Contains(str, "_statusCode:500"), true)
}