summaryrefslogtreecommitdiff
path: root/internal/tui/tui_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/tui/tui_test.go')
-rw-r--r--internal/tui/tui_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index ba0f8ed..a685719 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -1725,6 +1725,27 @@ func TestDashboardFooterShowsGlobalFilterStack(t *testing.T) {
}
}
+func TestFilterStackHistoryCapEvictsOldestEntries(t *testing.T) {
+ // Push maxFilterHistory+10 distinct filters and verify the slices never
+ // exceed the cap. The oldest entries must be evicted, and the most-recent
+ // maxFilterHistory entries must be retained.
+ fs := newFilterStack(globalfilter.Filter{})
+ for i := 0; i < maxFilterHistory+10; i++ {
+ f := globalfilter.Filter{}
+ f.FD = globalfilter.NewEqFilter(int64(i + 1)) // unique per iteration
+ fs.push(f, "")
+ }
+ if len(fs.history) > maxFilterHistory {
+ t.Fatalf("history exceeds cap: got %d, want <= %d", len(fs.history), maxFilterHistory)
+ }
+ if len(fs.stack) > maxFilterHistory {
+ t.Fatalf("stack exceeds cap: got %d, want <= %d", len(fs.stack), maxFilterHistory)
+ }
+ if len(fs.history) != len(fs.stack) {
+ t.Fatalf("history and stack lengths must match: history=%d stack=%d", len(fs.history), len(fs.stack))
+ }
+}
+
func TestProcessesTabEnterAppliesSelectedProcessAsGlobalFilter(t *testing.T) {
m := NewModel(-1, func(context.Context) error { return nil })
m.screen = ScreenDashboard