Skip to content

Commit

Permalink
fix: check if type matches for selected device
Browse files Browse the repository at this point in the history
fixes #315
  • Loading branch information
dundee committed Feb 15, 2024
1 parent 52079fe commit 86a6a1e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions tui/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ func TestDeviceSelected(t *testing.T) {
assert.Contains(t, ui.table.GetCell(1, 0).Text, "bbb")
}

func TestNilDeviceSelected(t *testing.T) {
simScreen := testapp.CreateSimScreen()
defer simScreen.Fini()

app := testapp.CreateMockedApp(false)
ui := CreateUI(app, simScreen, &bytes.Buffer{}, true, true, true, false, false)
ui.Analyzer = &testanalyze.MockedAnalyzer{}
ui.done = make(chan struct{})
ui.UseOldSizeBar()
ui.SetIgnoreDirPaths([]string{"/xxx"})

ui.deviceItemSelected(1, 0)

assert.Equal(t, 0, ui.table.GetRowCount())
}

func TestAnalyzePath(t *testing.T) {
ui := getAnalyzedPathMockedApp(t, true, true, true)

Expand Down
5 changes: 4 additions & 1 deletion tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ func (ui *UI) fileItemSelected(row, column int) {

func (ui *UI) deviceItemSelected(row, column int) {
var err error
selectedDevice := ui.table.GetCell(row, column).GetReference().(*device.Device)
selectedDevice, ok := ui.table.GetCell(row, column).GetReference().(*device.Device)
if !ok {
return
}

paths := device.GetNestedMountpointsPaths(selectedDevice.MountPoint, ui.devices)
ui.IgnoreDirPathPatterns, err = common.CreateIgnorePattern(paths)
Expand Down

0 comments on commit 86a6a1e

Please sign in to comment.