From 689f2239b31d230b2ba839f76c0940093cc2cbcb Mon Sep 17 00:00:00 2001 From: Daniel Milde Date: Tue, 6 Jun 2023 09:20:20 +0200 Subject: [PATCH] more tests --- cmd/gdu/app/app_test.go | 1 + tui/actions_test.go | 1 + tui/format_test.go | 24 ++++++++++++++++++++++++ tui/tui_test.go | 12 ++++++++++++ 4 files changed, 38 insertions(+) diff --git a/cmd/gdu/app/app_test.go b/cmd/gdu/app/app_test.go index 2aa5cf1dd..10240a951 100644 --- a/cmd/gdu/app/app_test.go +++ b/cmd/gdu/app/app_test.go @@ -185,6 +185,7 @@ func TestAnalyzePathWithStyle(t *testing.T) { ProgressModal: ProgressModalOpts{ CurrentItemNameMaxLen: 10, }, + UseOldSizeBar: true, }, }, []string{"test_dir"}, diff --git a/tui/actions_test.go b/tui/actions_test.go index 59c36a570..c64212797 100644 --- a/tui/actions_test.go +++ b/tui/actions_test.go @@ -63,6 +63,7 @@ func TestDeviceSelected(t *testing.T) { 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"}) err := ui.ListDevices(getDevicesInfoMock()) diff --git a/tui/format_test.go b/tui/format_test.go index 81d5b57ef..97f8d1d1e 100644 --- a/tui/format_test.go +++ b/tui/format_test.go @@ -124,3 +124,27 @@ func TestSizeBar(t *testing.T) { assert.Contains(t, ui.formatFileRow(file, file.GetUsage(), file.GetSize(), false), "██████████▏Aaa") } + +func TestOldSizeBar(t *testing.T) { + simScreen := testapp.CreateSimScreen() + defer simScreen.Fini() + + app := testapp.CreateMockedApp(true) + ui := CreateUI(app, simScreen, &bytes.Buffer{}, false, false, false, false, false) + ui.markedRows[0] = struct{}{} + ui.useOldSizeBar = true + + dir := &analyze.Dir{ + File: &analyze.File{ + Usage: 20, + }, + } + + file := &analyze.File{ + Name: "Aaa", + Parent: dir, + Usage: 10, + } + + assert.Contains(t, ui.formatFileRow(file, dir.GetUsage(), dir.GetSize(), false), "[##### ] Aaa") +} diff --git a/tui/tui_test.go b/tui/tui_test.go index 9a5a58457..db2c5ce06 100644 --- a/tui/tui_test.go +++ b/tui/tui_test.go @@ -438,6 +438,18 @@ func TestSetCurrentItemNameMaxLen(t *testing.T) { assert.Equal(t, ui.currentItemNameMaxLen, 5) } +func TestUseOldSizeBar(t *testing.T) { + simScreen := testapp.CreateSimScreen() + defer simScreen.Fini() + + app := testapp.CreateMockedApp(true) + ui := CreateUI(app, simScreen, &bytes.Buffer{}, false, true, false, false, false) + + ui.UseOldSizeBar() + + assert.Equal(t, ui.useOldSizeBar, true) +} + // nolint: deadcode,unused // Why: for debugging func printScreen(simScreen tcell.SimulationScreen) { b, _, _ := simScreen.GetContents()