Skip to content

Commit

Permalink
[ISSUE-1096] - Put back code from previous PR and removed invalid tes…
Browse files Browse the repository at this point in the history
…t case

Signed-off-by: Eddie Pavkovic <[email protected]>
  • Loading branch information
eddiepavkovic committed Feb 26, 2024
1 parent dfacddf commit c0a1c50
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
8 changes: 1 addition & 7 deletions pkg/base/linuxutils/lsblk/lsblk.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,7 @@ func (l *LSBLK) GetBlockDevices(device string) ([]BlockDevice, error) {
// Receives an instance of drivecrd.Drive struct
// Returns drive's path based on provided drivecrd.Drive or error if something went wrong
func (l *LSBLK) SearchDrivePath(drive *api.Drive) (string, error) {
// device path might be already set by hwmgr
device := drive.Path
if device != "" {
return device, nil
}

device = ""
device := ""
// try to find it with lsblk
lsblkOut, err := l.GetBlockDevices("")
if err != nil {
Expand Down
10 changes: 1 addition & 9 deletions pkg/base/linuxutils/lsblk/lsblk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ func TestLSBLK_SearchDrivePath_Success(t *testing.T) {
e := &mocks.GoMockExecutor{}
l := NewLSBLK(testLogger)
l.e = e
// path is in drive spec
dCR := testDriveCR
path := "/dev/sda"
dCR.Spec.Path = path

res, err := l.SearchDrivePath(&dCR.Spec)
assert.Nil(t, err)
assert.Equal(t, path, res)

// got from lsblk output
e.On("RunCmd", allDevicesCmd).Return(mocks.LsblkTwoDevicesStr, "", nil)
Expand All @@ -100,7 +92,7 @@ func TestLSBLK_SearchDrivePath_Success(t *testing.T) {
d2CR := testDriveCR
d2CR.Spec.SerialNumber = sn

res, err = l.SearchDrivePath(&d2CR.Spec)
res, err := l.SearchDrivePath(&d2CR.Spec)
assert.Nil(t, err)
assert.Equal(t, expectedDevice, res)
}
Expand Down

0 comments on commit c0a1c50

Please sign in to comment.