Fixed typos in inventory pkg
Signed-off-by: bijayasharma <vetbijaya@gmail.com> Change-Id: I8da797a6883df63adf6089743faa757d1099ef82
This commit is contained in:
parent
77268cd1d0
commit
c50286d015
@ -32,19 +32,19 @@ type CommandOptions struct {
|
||||
IsoURL string
|
||||
Timeout time.Duration
|
||||
|
||||
Invetnory ifc.Inventory
|
||||
Inventory ifc.Inventory
|
||||
}
|
||||
|
||||
// NewOptions options constructor
|
||||
func NewOptions(i ifc.Inventory) *CommandOptions {
|
||||
return &CommandOptions{
|
||||
Invetnory: i,
|
||||
Inventory: i,
|
||||
}
|
||||
}
|
||||
|
||||
// BMHAction performs an action against BaremetalHost objects
|
||||
func (o *CommandOptions) BMHAction(op ifc.BaremetalOperation) error {
|
||||
bmhInventory, err := o.Invetnory.BaremetalInventory()
|
||||
bmhInventory, err := o.Inventory.BaremetalInventory()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -86,7 +86,7 @@ func (o *CommandOptions) PowerStatus(w io.Writer) error {
|
||||
}
|
||||
|
||||
func (o *CommandOptions) getHost() (remoteifc.Client, error) {
|
||||
bmhInventory, err := o.Invetnory.BaremetalInventory()
|
||||
bmhInventory, err := o.Inventory.BaremetalInventory()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -31,12 +31,12 @@ import (
|
||||
func TestCommandOptions(t *testing.T) {
|
||||
t.Run("error BMHAction bmh inventory", func(t *testing.T) {
|
||||
inv := &mockinventory.MockInventory{}
|
||||
expetedErr := fmt.Errorf("bmh inventory error")
|
||||
inv.On("BaremetalInventory").Once().Return(nil, expetedErr)
|
||||
expectedErr := fmt.Errorf("bmh inventory error")
|
||||
inv.On("BaremetalInventory").Once().Return(nil, expectedErr)
|
||||
|
||||
co := inventory.NewOptions(inv)
|
||||
actualErr := co.BMHAction(ifc.BaremetalOperationPowerOn)
|
||||
assert.Equal(t, expetedErr, actualErr)
|
||||
assert.Equal(t, expectedErr, actualErr)
|
||||
})
|
||||
|
||||
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) {
|
||||
expetedErr := fmt.Errorf("SelectOne inventory error")
|
||||
expectedErr := fmt.Errorf("SelectOne inventory error")
|
||||
bmhInv := &mockinventory.MockBMHInventory{}
|
||||
bmhInv.On("SelectOne").Once().Return(nil, expetedErr)
|
||||
bmhInv.On("SelectOne").Once().Return(nil, expectedErr)
|
||||
|
||||
inv := &mockinventory.MockInventory{}
|
||||
inv.On("BaremetalInventory").Once().Return(bmhInv, nil)
|
||||
@ -62,27 +62,27 @@ func TestCommandOptions(t *testing.T) {
|
||||
co := inventory.NewOptions(inv)
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
actualErr := co.PowerStatus(buf)
|
||||
assert.Equal(t, expetedErr, actualErr)
|
||||
assert.Equal(t, expectedErr, actualErr)
|
||||
assert.Len(t, buf.Bytes(), 0)
|
||||
})
|
||||
|
||||
t.Run("error PowerStatus BMHInventory", func(t *testing.T) {
|
||||
inv := &mockinventory.MockInventory{}
|
||||
|
||||
expetedErr := fmt.Errorf("bmh inventory error")
|
||||
inv.On("BaremetalInventory").Once().Return(nil, expetedErr)
|
||||
expectedErr := fmt.Errorf("bmh inventory error")
|
||||
inv.On("BaremetalInventory").Once().Return(nil, expectedErr)
|
||||
|
||||
co := inventory.NewOptions(inv)
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
actualErr := co.PowerStatus(buf)
|
||||
assert.Equal(t, expetedErr, actualErr)
|
||||
assert.Equal(t, expectedErr, actualErr)
|
||||
assert.Len(t, buf.Bytes(), 0)
|
||||
})
|
||||
|
||||
t.Run("error PowerStatus SystemPowerStatus", func(t *testing.T) {
|
||||
expetedErr := fmt.Errorf("SystemPowerStatus error")
|
||||
expectedErr := fmt.Errorf("SystemPowerStatus error")
|
||||
host := &redfishutils.MockClient{}
|
||||
host.On("SystemPowerStatus").Once().Return(power.StatusUnknown, expetedErr)
|
||||
host.On("SystemPowerStatus").Once().Return(power.StatusUnknown, expectedErr)
|
||||
|
||||
bmhInv := &mockinventory.MockBMHInventory{}
|
||||
bmhInv.On("SelectOne").Once().Return(host, nil)
|
||||
@ -93,7 +93,7 @@ func TestCommandOptions(t *testing.T) {
|
||||
co := inventory.NewOptions(inv)
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
actualErr := co.PowerStatus(buf)
|
||||
assert.Equal(t, expetedErr, actualErr)
|
||||
assert.Equal(t, expectedErr, actualErr)
|
||||
assert.Len(t, buf.Bytes(), 0)
|
||||
})
|
||||
|
||||
@ -152,11 +152,11 @@ func TestCommandOptions(t *testing.T) {
|
||||
t.Run("error RemoteDirect BMHInventory", func(t *testing.T) {
|
||||
inv := &mockinventory.MockInventory{}
|
||||
|
||||
expetedErr := fmt.Errorf("bmh inventory error")
|
||||
inv.On("BaremetalInventory").Once().Return(nil, expetedErr)
|
||||
expectedErr := fmt.Errorf("bmh inventory error")
|
||||
inv.On("BaremetalInventory").Once().Return(nil, expectedErr)
|
||||
|
||||
co := inventory.NewOptions(inv)
|
||||
actualErr := co.RemoteDirect()
|
||||
assert.Equal(t, expetedErr, actualErr)
|
||||
assert.Equal(t, expectedErr, actualErr)
|
||||
})
|
||||
}
|
||||
|
@ -23,22 +23,22 @@ import (
|
||||
"opendev.org/airship/airshipctl/pkg/inventory/ifc"
|
||||
)
|
||||
|
||||
var _ ifc.Inventory = Invetnory{}
|
||||
var _ ifc.Inventory = Inventory{}
|
||||
|
||||
// Invetnory implementation of the interface
|
||||
type Invetnory struct {
|
||||
// Inventory implementation of the interface
|
||||
type Inventory struct {
|
||||
config.Factory
|
||||
}
|
||||
|
||||
// NewInventory inventory constructor
|
||||
func NewInventory(f config.Factory) ifc.Inventory {
|
||||
return Invetnory{
|
||||
return Inventory{
|
||||
Factory: f,
|
||||
}
|
||||
}
|
||||
|
||||
// BaremetalInventory implementation of the interface
|
||||
func (i Invetnory) BaremetalInventory() (ifc.BaremetalInventory, error) {
|
||||
func (i Inventory) BaremetalInventory() (ifc.BaremetalInventory, error) {
|
||||
cfg, err := i.Factory()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -132,7 +132,7 @@ func toCommandOptions(i inventoryifc.Inventory,
|
||||
}
|
||||
|
||||
return &inventory.CommandOptions{
|
||||
Invetnory: i,
|
||||
Inventory: i,
|
||||
IsoURL: spec.OperationOptions.RemoteDirect.ISOURL,
|
||||
Labels: spec.HostSelector.LabelSelector,
|
||||
Name: spec.HostSelector.Name,
|
||||
|
Loading…
Reference in New Issue
Block a user