Skip to content

Commit

Permalink
NVMe host name could be null
Browse files Browse the repository at this point in the history
  • Loading branch information
baoy1 committed Oct 24, 2024
1 parent da6863d commit c49dc1d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions nvme_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (s *System) GetAllNvmeHosts() ([]types.NvmeHost, error) {
}

// GetNvmeHostByID returns an NVMe host searched by id
func (s *System) GetNvmeHostByID(id string) (*NvmeHost, error) {
func (s *System) GetNvmeHostByID(id string) (*types.NvmeHost, error) {
defer TimeSpent("GetNvmeHostByID", time.Now())

path := fmt.Sprintf("api/instances/Sdc::%v", id)
Expand All @@ -71,7 +71,7 @@ func (s *System) GetNvmeHostByID(id string) (*NvmeHost, error) {
return nil, err
}

return NewNvmeHost(s.client, &nvmeHost), nil
return &nvmeHost, nil
}

// CreateNvmeHost creates a new NVMe host
Expand Down
12 changes: 6 additions & 6 deletions nvme_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func Test_GetAllNvmeHosts(t *testing.T) {
}

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

responseJSON := `{
Expand Down Expand Up @@ -201,19 +201,19 @@ func Test_GetNvmeHostByID(t *testing.T) {
]
}`

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

checkName := func(name string) func(t *testing.T, host *NvmeHost, err error) {
return func(t *testing.T, host *NvmeHost, _ error) {
assert.Equal(t, host.NvmeHost.Name, name)
checkName := func(name string) func(t *testing.T, host *types.NvmeHost, err error) {
return func(t *testing.T, host *types.NvmeHost, _ error) {
assert.Equal(t, host.Name, name)
}
}

hasError := func(t *testing.T, _ *NvmeHost, err error) {
hasError := func(t *testing.T, _ *types.NvmeHost, err error) {
if err == nil {
t.Fatalf("expected error")
}
Expand Down
2 changes: 1 addition & 1 deletion types/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,7 @@ type ChangeNvmeHostMaxNumSysPortsParam struct {

// NvmeHostParam defines struct for creating an NVMe host
type NvmeHostParam struct {
Name string `json:"name"`
Name string `json:"name,omitempty"`
Nqn string `json:"nqn"`
MaxNumPaths IntString `json:"maxNumPaths,omitempty"`
MaxNumSysPorts IntString `json:"maxNumSysPorts,omitempty"`
Expand Down

0 comments on commit c49dc1d

Please sign in to comment.