diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-24 08:45:38 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-24 08:45:38 +0200 |
| commit | e5116514c33b2fce6ce2fc7904d6720c5236221f (patch) | |
| tree | e5bc8c9ba37836305ec1d095573535fb8344cbe7 /internal/tui/tui_test.go | |
| parent | b01e24374398eb3d343e9472f3262668039db56c (diff) | |
tui: wire eventloop stats engine into dashboard snapshots
Diffstat (limited to 'internal/tui/tui_test.go')
| -rw-r--r-- | internal/tui/tui_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go index 3801813..40ea67b 100644 --- a/internal/tui/tui_test.go +++ b/internal/tui/tui_test.go @@ -3,6 +3,7 @@ package tui import ( "context" "errors" + "ior/internal/statsengine" "strings" "testing" "time" @@ -164,3 +165,27 @@ func TestQuitInvokesTraceStop(t *testing.T) { t.Fatalf("expected stopTrace to be invoked on quit") } } + +type fakeDashboardSource struct { + snap *statsengine.Snapshot +} + +func (f fakeDashboardSource) Snapshot() *statsengine.Snapshot { + return f.snap +} + +func TestDashboardRefreshPicksLateBoundSource(t *testing.T) { + orig := getDashboardSnapshotSource() + defer SetDashboardSnapshotSource(orig) + + SetDashboardSnapshotSource(nil) + d := newDashboardModel(nil) + + want := &statsengine.Snapshot{TotalSyscalls: 77} + SetDashboardSnapshotSource(fakeDashboardSource{snap: want}) + + d.refresh() + if d.latest != want { + t.Fatalf("expected dashboard refresh to bind and use latest global source") + } +} |
