Skip to content

Commit

Permalink
review comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
KshitijaKakde committed Oct 17, 2023
1 parent 4d6fc0d commit 893a09f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
16 changes: 6 additions & 10 deletions system_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ import (
types "github.com/dell/goscaleio/types/v1"
)

type QuerySystemLimitsParam struct {
}

// GetSystemLimits gets list of sytem limits

func (c *Client) GetSystemLimits() (systemLimits *types.Limit, err error) {
func (c *Client) GetSystemLimits() (systemLimits *types.QuerySystemLimitsResponse, err error) {
defer TimeSpent("GetSystemLimits", time.Now())
var body QuerySystemLimitsParam
var body *types.QuerySystemLimitsParam
path := "/api/instances/System/action/querySystemLimits"
err = c.getJSONWithRetry(
http.MethodPost, path, body, &systemLimits)
Expand All @@ -41,16 +37,16 @@ func (c *Client) GetSystemLimits() (systemLimits *types.Limit, err error) {
// GetMaxVol returns max volume size in GB
func (c *Client) GetMaxVol() (systemLimits string, err error) {
defer TimeSpent("GetMaxVol", time.Now())
maxLimitType, err := c.GetSystemLimits()
sysLimit, err := c.GetSystemLimits()

if err != nil {
return "", err
}

for _, systemType := range maxLimitType.SystemLimitEntryList {
for _, systemLimit := range sysLimit.SystemLimitEntryList {

if systemType.Type == "volumeSizeGb" {
return systemType.MaxVal, nil
if systemLimit.Type == "volumeSizeGb" {
return systemLimit.MaxVal, nil
}

}
Expand Down
22 changes: 11 additions & 11 deletions system_limit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,41 @@ import (
)

func TestGetSystemLimits(t *testing.T) {
type checkFn func(*testing.T, *types.Limit, error)
type checkFn func(*testing.T, *types.QuerySystemLimitsResponse, error)
check := func(fns ...checkFn) []checkFn { return fns }

hasNoError := func(t *testing.T, syslimit *types.Limit, err error) {
hasNoError := func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) {
if err != nil {
t.Fatalf("expected no error")
}
}

hasError := func(t *testing.T, syslimit *types.Limit, err error) {
hasError := func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) {
if err == nil {
t.Fatalf("expected error")
}
}

checkLimitType := func(expectedType string) func(t *testing.T, syslimit *types.Limit, err error) {
return func(t *testing.T, syslimit *types.Limit, err error) {
checkLimitType := func(expectedType string) func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) {
return func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) {
if err == nil {
// Add your custom assertions here to check the syslimit.Type.
assert.Equal(t, expectedType, syslimit.SystemLimitEntryList[0].Type)
}
}
}

checkLimitDescription := func(expectedDescription string) func(t *testing.T, syslimit *types.Limit, err error) {
return func(t *testing.T, syslimit *types.Limit, err error) {
checkLimitDescription := func(expectedDescription string) func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) {
return func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) {
if err == nil {
// Add your custom assertions here to check the syslimit.Description.
assert.Equal(t, expectedDescription, syslimit.SystemLimitEntryList[0].Description)
}
}
}

checkLimitMaxVal := func(expectedMaxVal string) func(t *testing.T, syslimit *types.Limit, err error) {
return func(t *testing.T, syslimit *types.Limit, err error) {
checkLimitMaxVal := func(expectedMaxVal string) func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) {
return func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) {
if err == nil {
// Add your custom assertions here to check the syslimit.MaxVal.
assert.Equal(t, expectedMaxVal, syslimit.SystemLimitEntryList[0].MaxVal)
Expand All @@ -81,8 +81,8 @@ func TestGetSystemLimits(t *testing.T) {
}

// Simulate a successful response for GetSystemLimits.
resp := types.Limit{
SystemLimitEntryList: []types.QuerySystemLimits{
resp := types.QuerySystemLimitsResponse{
SystemLimitEntryList: []types.SystemLimits{
{
Type: "volumeSizeGb",
Description: "Maximum volume size in GB",
Expand Down
11 changes: 7 additions & 4 deletions types/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1739,14 +1739,17 @@ type MDMQueueCommandDetails struct {
AllowedPhase string `json:"allowedPhase,omitempty"`
}

// QuerySystemLimits defines struct for query system limits
type QuerySystemLimits struct {
// SystemLimits defines struct for system limits
type SystemLimits struct {
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
MaxVal string `json:"maxVal,omitempty"`
}

// SystemLimitEntryList defines struct for system limit entryList
type Limit struct {
SystemLimitEntryList []QuerySystemLimits `json:"systemLimitEntryList"`
type QuerySystemLimitsResponse struct {
SystemLimitEntryList []SystemLimits `json:"systemLimitEntryList"`
}

type QuerySystemLimitsParam struct {
}

0 comments on commit 893a09f

Please sign in to comment.