diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-27 08:29:07 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-27 08:29:07 +0300 |
| commit | f660ad10bccb529e7176b293ef4be05aeb612074 (patch) | |
| tree | 1d2387263c59828dde1c2c56cd5c72b3f9787214 /internal/tui/flamegraph/model_test.go | |
| parent | 3f7ddc5eb12db3b0677cc51653b1c26e1d1b84fd (diff) | |
flamegraph: table-drive metric cycles and semantic colors (9p)
Diffstat (limited to 'internal/tui/flamegraph/model_test.go')
| -rw-r--r-- | internal/tui/flamegraph/model_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/tui/flamegraph/model_test.go b/internal/tui/flamegraph/model_test.go index f31a9a1..5445896 100644 --- a/internal/tui/flamegraph/model_test.go +++ b/internal/tui/flamegraph/model_test.go @@ -1079,6 +1079,40 @@ func TestControlHeightToggleReconfiguresLiveTrieHeightField(t *testing.T) { } } +func TestControlMetricToggleUnknownValueFallsBackToCount(t *testing.T) { + liveTrie := coreflamegraph.NewLiveTrie([]string{"comm", "path", "tracepoint"}, "count", "") + m := NewModel(liveTrie) + m.countField = "unexpected" + + m = pressFlameKey(t, m, tea.KeyPressMsg{Code: []rune{'b'}[0], Text: "b"}) + if got, want := m.countField, "count"; got != want { + t.Fatalf("expected model count field fallback %q, got %q", want, got) + } + if got, want := liveTrie.CountField(), "count"; got != want { + t.Fatalf("expected live trie count field fallback %q, got %q", want, got) + } + if got, want := m.statusMessage, "Metric: events (new baseline)"; got != want { + t.Fatalf("expected metric fallback status %q, got %q", want, got) + } +} + +func TestControlHeightToggleUnknownValueFallsBackToOff(t *testing.T) { + liveTrie := coreflamegraph.NewLiveTrie([]string{"comm", "path", "tracepoint"}, "count", "") + m := NewModel(liveTrie) + m.heightField = "unexpected" + + m = pressFlameKey(t, m, tea.KeyPressMsg{Code: []rune{'v'}[0], Text: "v"}) + if got, want := m.heightField, ""; got != want { + t.Fatalf("expected model height field fallback %q, got %q", want, got) + } + if got, want := liveTrie.HeightField(), ""; got != want { + t.Fatalf("expected live trie height field fallback %q, got %q", want, got) + } + if got, want := m.statusMessage, "Height: off (new baseline)"; got != want { + t.Fatalf("expected height fallback status %q, got %q", want, got) + } +} + func TestNewModelAlignsPresetIndexToLiveTrieFields(t *testing.T) { liveTrie := coreflamegraph.NewLiveTrie([]string{"comm", "path", "tracepoint"}, "count", "count") m := NewModel(liveTrie) |
