Fixed typos in inventory pkg

Signed-off-by: bijayasharma <vetbijaya@gmail.com>
Change-Id: I8da797a6883df63adf6089743faa757d1099ef82
This commit is contained in:
bijayasharma 2021-02-09 16:03:53 -05:00 committed by Bijaya Sharma
parent 77268cd1d0
commit c50286d015
4 changed files with 25 additions and 25 deletions

View File

@ -32,19 +32,19 @@ type CommandOptions struct {
IsoURL string IsoURL string
Timeout time.Duration Timeout time.Duration
Invetnory ifc.Inventory Inventory ifc.Inventory
} }
// NewOptions options constructor // NewOptions options constructor
func NewOptions(i ifc.Inventory) *CommandOptions { func NewOptions(i ifc.Inventory) *CommandOptions {
return &CommandOptions{ return &CommandOptions{
Invetnory: i, Inventory: i,
} }
} }
// BMHAction performs an action against BaremetalHost objects // BMHAction performs an action against BaremetalHost objects
func (o *CommandOptions) BMHAction(op ifc.BaremetalOperation) error { func (o *CommandOptions) BMHAction(op ifc.BaremetalOperation) error {
bmhInventory, err := o.Invetnory.BaremetalInventory() bmhInventory, err := o.Inventory.BaremetalInventory()
if err != nil { if err != nil {
return err return err
} }
@ -86,7 +86,7 @@ func (o *CommandOptions) PowerStatus(w io.Writer) error {
} }
func (o *CommandOptions) getHost() (remoteifc.Client, error) { func (o *CommandOptions) getHost() (remoteifc.Client, error) {
bmhInventory, err := o.Invetnory.BaremetalInventory() bmhInventory, err := o.Inventory.BaremetalInventory()
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -31,12 +31,12 @@ import (
func TestCommandOptions(t *testing.T) { func TestCommandOptions(t *testing.T) {
t.Run("error BMHAction bmh inventory", func(t *testing.T) { t.Run("error BMHAction bmh inventory", func(t *testing.T) {
inv := &mockinventory.MockInventory{} inv := &mockinventory.MockInventory{}
expetedErr := fmt.Errorf("bmh inventory error") expectedErr := fmt.Errorf("bmh inventory error")
inv.On("BaremetalInventory").Once().Return(nil, expetedErr) inv.On("BaremetalInventory").Once().Return(nil, expectedErr)
co := inventory.NewOptions(inv) co := inventory.NewOptions(inv)
actualErr := co.BMHAction(ifc.BaremetalOperationPowerOn) actualErr := co.BMHAction(ifc.BaremetalOperationPowerOn)
assert.Equal(t, expetedErr, actualErr) assert.Equal(t, expectedErr, actualErr)
}) })
t.Run("success BMHAction", func(t *testing.T) { t.Run("success BMHAction", func(t *testing.T) {
@ -52,9 +52,9 @@ func TestCommandOptions(t *testing.T) {
}) })
t.Run("error PowerStatus SelectOne", func(t *testing.T) { t.Run("error PowerStatus SelectOne", func(t *testing.T) {
expetedErr := fmt.Errorf("SelectOne inventory error") expectedErr := fmt.Errorf("SelectOne inventory error")
bmhInv := &mockinventory.MockBMHInventory{} bmhInv := &mockinventory.MockBMHInventory{}
bmhInv.On("SelectOne").Once().Return(nil, expetedErr) bmhInv.On("SelectOne").Once().Return(nil, expectedErr)
inv := &mockinventory.MockInventory{} inv := &mockinventory.MockInventory{}
inv.On("BaremetalInventory").Once().Return(bmhInv, nil) inv.On("BaremetalInventory").Once().Return(bmhInv, nil)
@ -62,27 +62,27 @@ func TestCommandOptions(t *testing.T) {
co := inventory.NewOptions(inv) co := inventory.NewOptions(inv)
buf := bytes.NewBuffer([]byte{}) buf := bytes.NewBuffer([]byte{})
actualErr := co.PowerStatus(buf) actualErr := co.PowerStatus(buf)
assert.Equal(t, expetedErr, actualErr) assert.Equal(t, expectedErr, actualErr)
assert.Len(t, buf.Bytes(), 0) assert.Len(t, buf.Bytes(), 0)
}) })
t.Run("error PowerStatus BMHInventory", func(t *testing.T) { t.Run("error PowerStatus BMHInventory", func(t *testing.T) {
inv := &mockinventory.MockInventory{} inv := &mockinventory.MockInventory{}
expetedErr := fmt.Errorf("bmh inventory error") expectedErr := fmt.Errorf("bmh inventory error")
inv.On("BaremetalInventory").Once().Return(nil, expetedErr) inv.On("BaremetalInventory").Once().Return(nil, expectedErr)
co := inventory.NewOptions(inv) co := inventory.NewOptions(inv)
buf := bytes.NewBuffer([]byte{}) buf := bytes.NewBuffer([]byte{})
actualErr := co.PowerStatus(buf) actualErr := co.PowerStatus(buf)
assert.Equal(t, expetedErr, actualErr) assert.Equal(t, expectedErr, actualErr)
assert.Len(t, buf.Bytes(), 0) assert.Len(t, buf.Bytes(), 0)
}) })
t.Run("error PowerStatus SystemPowerStatus", func(t *testing.T) { t.Run("error PowerStatus SystemPowerStatus", func(t *testing.T) {
expetedErr := fmt.Errorf("SystemPowerStatus error") expectedErr := fmt.Errorf("SystemPowerStatus error")
host := &redfishutils.MockClient{} host := &redfishutils.MockClient{}
host.On("SystemPowerStatus").Once().Return(power.StatusUnknown, expetedErr) host.On("SystemPowerStatus").Once().Return(power.StatusUnknown, expectedErr)
bmhInv := &mockinventory.MockBMHInventory{} bmhInv := &mockinventory.MockBMHInventory{}
bmhInv.On("SelectOne").Once().Return(host, nil) bmhInv.On("SelectOne").Once().Return(host, nil)
@ -93,7 +93,7 @@ func TestCommandOptions(t *testing.T) {
co := inventory.NewOptions(inv) co := inventory.NewOptions(inv)
buf := bytes.NewBuffer([]byte{}) buf := bytes.NewBuffer([]byte{})
actualErr := co.PowerStatus(buf) actualErr := co.PowerStatus(buf)
assert.Equal(t, expetedErr, actualErr) assert.Equal(t, expectedErr, actualErr)
assert.Len(t, buf.Bytes(), 0) assert.Len(t, buf.Bytes(), 0)
}) })
@ -152,11 +152,11 @@ func TestCommandOptions(t *testing.T) {
t.Run("error RemoteDirect BMHInventory", func(t *testing.T) { t.Run("error RemoteDirect BMHInventory", func(t *testing.T) {
inv := &mockinventory.MockInventory{} inv := &mockinventory.MockInventory{}
expetedErr := fmt.Errorf("bmh inventory error") expectedErr := fmt.Errorf("bmh inventory error")
inv.On("BaremetalInventory").Once().Return(nil, expetedErr) inv.On("BaremetalInventory").Once().Return(nil, expectedErr)
co := inventory.NewOptions(inv) co := inventory.NewOptions(inv)
actualErr := co.RemoteDirect() actualErr := co.RemoteDirect()
assert.Equal(t, expetedErr, actualErr) assert.Equal(t, expectedErr, actualErr)
}) })
} }

View File

@ -23,22 +23,22 @@ import (
"opendev.org/airship/airshipctl/pkg/inventory/ifc" "opendev.org/airship/airshipctl/pkg/inventory/ifc"
) )
var _ ifc.Inventory = Invetnory{} var _ ifc.Inventory = Inventory{}
// Invetnory implementation of the interface // Inventory implementation of the interface
type Invetnory struct { type Inventory struct {
config.Factory config.Factory
} }
// NewInventory inventory constructor // NewInventory inventory constructor
func NewInventory(f config.Factory) ifc.Inventory { func NewInventory(f config.Factory) ifc.Inventory {
return Invetnory{ return Inventory{
Factory: f, Factory: f,
} }
} }
// BaremetalInventory implementation of the interface // BaremetalInventory implementation of the interface
func (i Invetnory) BaremetalInventory() (ifc.BaremetalInventory, error) { func (i Inventory) BaremetalInventory() (ifc.BaremetalInventory, error) {
cfg, err := i.Factory() cfg, err := i.Factory()
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -132,7 +132,7 @@ func toCommandOptions(i inventoryifc.Inventory,
} }
return &inventory.CommandOptions{ return &inventory.CommandOptions{
Invetnory: i, Inventory: i,
IsoURL: spec.OperationOptions.RemoteDirect.ISOURL, IsoURL: spec.OperationOptions.RemoteDirect.ISOURL,
Labels: spec.HostSelector.LabelSelector, Labels: spec.HostSelector.LabelSelector,
Name: spec.HostSelector.Name, Name: spec.HostSelector.Name,