Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check if type matches for selected device #318

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading