diff --git a/pkg/analyze/file_test.go b/pkg/analyze/file_test.go index 591f22ccb..5af40a5b3 100644 --- a/pkg/analyze/file_test.go +++ b/pkg/analyze/file_test.go @@ -402,3 +402,62 @@ func TestGetPathWithoutLeadingSlash(t *testing.T) { assert.Equal(t, "C:\\", dir.GetPath()) } + +func TestSetParent(t *testing.T) { + dir := &Dir{ + File: &File{ + Name: "root", + Size: 5, + Usage: 12, + }, + ItemCount: 3, + BasePath: "/", + } + file := &File{ + Name: "xxx", + Mli: 5, + } + file.SetParent(dir) + + assert.Equal(t, "root", file.GetParent().GetName()) +} + +func TestGetFiles(t *testing.T) { + file := &File{ + Name: "xxx", + Mli: 5, + } + dir := &Dir{ + File: &File{ + Name: "root", + Size: 5, + Usage: 12, + }, + ItemCount: 3, + BasePath: "/", + Files: fs.Files{file}, + } + + assert.Equal(t, file.Name, dir.GetFiles()[0].GetName()) + assert.Equal(t, fs.Files{}, file.GetFiles()) +} + +func TestSetFilesPanicsOnFile(t *testing.T) { + file := &File{ + Name: "xxx", + Mli: 5, + } + assert.Panics(t, func() { + file.SetFiles(fs.Files{file}) + }) +} + +func TestAddFilePanicsOnFile(t *testing.T) { + file := &File{ + Name: "xxx", + Mli: 5, + } + assert.Panics(t, func() { + file.AddFile(file) + }) +} diff --git a/tui/actions_test.go b/tui/actions_test.go index 872c0f421..746d21cf9 100644 --- a/tui/actions_test.go +++ b/tui/actions_test.go @@ -361,6 +361,9 @@ func TestShowInfoWithHardlinks(t *testing.T) { assert.Equal(t, "test_dir", ui.currentDir.GetName()) ui.keyPressed(tcell.NewEventKey(tcell.KeyRight, 'l', 0)) + ui.table.Select(1, 0) + ui.keyPressed(tcell.NewEventKey(tcell.KeyRight, 'l', 0)) + ui.table.Select(1, 0) ui.keyPressed(tcell.NewEventKey(tcell.KeyRune, 'i', 0)) assert.True(t, ui.pages.HasPage("info"))