diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-24 08:38:19 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-24 08:38:19 +0200 |
| commit | b01e24374398eb3d343e9472f3262668039db56c (patch) | |
| tree | 139a9e02946f635adaeedb8a61fa150c874c17ff /internal/tui/dashboard/syscalls_test.go | |
| parent | 24b401ac9c6a1f80b5ba7f446f1fd3e3ddf02b5c (diff) | |
tui: add dashboard syscalls table tab
Diffstat (limited to 'internal/tui/dashboard/syscalls_test.go')
| -rw-r--r-- | internal/tui/dashboard/syscalls_test.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/internal/tui/dashboard/syscalls_test.go b/internal/tui/dashboard/syscalls_test.go new file mode 100644 index 0000000..f998f74 --- /dev/null +++ b/internal/tui/dashboard/syscalls_test.go @@ -0,0 +1,52 @@ +package dashboard + +import ( + "strings" + "testing" + + "ior/internal/statsengine" +) + +func TestRenderSyscallsIncludesHeaders(t *testing.T) { + snap := statsengine.NewSnapshot( + nil, nil, nil, + []statsengine.SyscallSnapshot{ + {Name: "write", Count: 5, RatePerSec: 1.2, Bytes: 1024, Errors: 1}, + {Name: "read", Count: 10, RatePerSec: 2.4, Bytes: 2048, Errors: 0}, + }, + nil, nil, + statsengine.HistogramSnapshot{}, + statsengine.HistogramSnapshot{}, + ) + + out := renderSyscalls(&snap, 120, 30) + for _, token := range []string{"Syscall", "Count", "Rate/s", "p95", "Errors"} { + if !strings.Contains(out, token) { + t.Fatalf("expected token %q in syscall table view", token) + } + } + if !strings.Contains(out, "read") { + t.Fatalf("expected syscall row in output") + } +} + +func TestFormatDurationNs(t *testing.T) { + if got := formatDurationNs(50); got != "50ns" { + t.Fatalf("unexpected ns formatting: %q", got) + } + if got := formatDurationNs(1500); !strings.Contains(got, "µs") { + t.Fatalf("expected µs formatting, got %q", got) + } + if got := formatDurationNs(2_500_000); !strings.Contains(got, "ms") { + t.Fatalf("expected ms formatting, got %q", got) + } +} + +func TestClampOffset(t *testing.T) { + if got := clampOffset(-5, 10); got != 0 { + t.Fatalf("expected 0 for negative offset, got %d", got) + } + if got := clampOffset(99, 4); got != 3 { + t.Fatalf("expected max index clamp, got %d", got) + } +} |
