diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-13 14:28:37 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-13 14:28:37 +0300 |
| commit | 27b94f917064948fa33141309a3f08deb40ffde2 (patch) | |
| tree | 0f1c63eba01da1cc89fbbedcfe71cdcb55b06cb0 /internal/streamrow/row_test.go | |
| parent | 140d6c0fe472f112170022b9831dfe700698f382 (diff) | |
improve unit test coverage to >=60% in probes, common, export, streamrow, pidpicker, tui/export
Before: probes=30%, tui/common=41%, export=0%, streamrow=25%, pidpicker=59%, tui/export=45%
After: probes=89%, tui/common=97%, export=77%, streamrow=100%, pidpicker=73%, tui/export=99%
New test files cover RingBuffer push/wrap/reset, Row accessor methods, nil
Sequencer safety, SnapshotCSV nil and data paths, helper functions snapValue /
snapValueF / trendSummary, all table navigation keys, VisibleTableWindow/
ClampTableCol edge cases, RenderTableHeader/Row, PickerShortHelp, probe modal
navigation/search/toggle/view/error paths, truncateText/sanitizeOneLine,
export modal View rendering, key navigation, status messages, scanAllThreadsFrom,
readThreadInfo guards, formatProcess variants, and clamp helper.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/streamrow/row_test.go')
| -rw-r--r-- | internal/streamrow/row_test.go | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/internal/streamrow/row_test.go b/internal/streamrow/row_test.go index 17d6c40..ea63bcc 100644 --- a/internal/streamrow/row_test.go +++ b/internal/streamrow/row_test.go @@ -98,3 +98,64 @@ func TestNewWarningPopulatesSyntheticWarningFields(t *testing.T) { t.Fatalf("RetVal/IsError = %d/%v, want -1/true", got.RetVal, got.IsError) } } + +// TestRowValueAccessors verifies that all typed accessor methods return the +// underlying field values set on a Row. +func TestRowValueAccessors(t *testing.T) { + r := Row{ + Syscall: "read", + Comm: "cat", + FileName: "/etc/hosts", + PID: 10, + TID: 11, + FD: 3, + DurationNs: 500, + GapNs: 200, + Bytes: 1024, + RetVal: -1, + IsError: true, + } + + if r.SyscallValue() != "read" { + t.Fatalf("SyscallValue = %q, want read", r.SyscallValue()) + } + if r.CommValue() != "cat" { + t.Fatalf("CommValue = %q, want cat", r.CommValue()) + } + if r.FileValue() != "/etc/hosts" { + t.Fatalf("FileValue = %q, want /etc/hosts", r.FileValue()) + } + if r.PIDValue() != 10 { + t.Fatalf("PIDValue = %d, want 10", r.PIDValue()) + } + if r.TIDValue() != 11 { + t.Fatalf("TIDValue = %d, want 11", r.TIDValue()) + } + if r.FDValue() != 3 { + t.Fatalf("FDValue = %d, want 3", r.FDValue()) + } + if r.LatencyValue() != 500 { + t.Fatalf("LatencyValue = %d, want 500", r.LatencyValue()) + } + if r.GapValue() != 200 { + t.Fatalf("GapValue = %d, want 200", r.GapValue()) + } + if r.BytesValue() != 1024 { + t.Fatalf("BytesValue = %d, want 1024", r.BytesValue()) + } + if r.ReturnValue() != -1 { + t.Fatalf("ReturnValue = %d, want -1", r.ReturnValue()) + } + if !r.ErrorValue() { + t.Fatal("ErrorValue = false, want true") + } +} + +// TestSequencerNilSafeNext verifies that calling Next on a nil Sequencer returns +// 0 without panicking. +func TestSequencerNilSafeNext(t *testing.T) { + var s *Sequencer + if got := s.Next(); got != 0 { + t.Fatalf("nil Sequencer.Next() = %d, want 0", got) + } +} |
