summaryrefslogtreecommitdiff
path: root/internal/askcli/command_watch_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-31 10:16:46 +0300
committerPaul Buetow <paul@buetow.org>2026-05-31 10:16:46 +0300
commitf1f70af28d121e6ff379ed390ebb88a165e60bad (patch)
treedb9fad338dd443ebe40213f2fbd3acff632c7982 /internal/askcli/command_watch_test.go
parent0dfcb0f3fe6db144f02506df95e68707d9b5091c (diff)
ask: fix watch output to match regular commands by preserving terminal width detection
Diffstat (limited to 'internal/askcli/command_watch_test.go')
-rw-r--r--internal/askcli/command_watch_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/askcli/command_watch_test.go b/internal/askcli/command_watch_test.go
index 77d0fda..abd74ff 100644
--- a/internal/askcli/command_watch_test.go
+++ b/internal/askcli/command_watch_test.go
@@ -267,3 +267,29 @@ func TestHandleWatch_RejectsUnsafeSubcommands(t *testing.T) {
})
}
}
+
+type mockFdWriter struct {
+ io.Writer
+ fd uintptr
+}
+
+func (m *mockFdWriter) Fd() uintptr { return m.fd }
+
+func TestDeferredWriter_PreservesFd(t *testing.T) {
+ w := &mockFdWriter{Writer: &bytes.Buffer{}, fd: 42}
+ dw := &deferredWriter{w: w}
+ if got := dw.Fd(); got != 42 {
+ t.Fatalf("Fd() = %d, want 42", got)
+ }
+ _, _ = dw.Write([]byte("hello"))
+ if !bytes.Equal(dw.buf.Bytes(), []byte("hello")) {
+ t.Fatalf("buf = %q, want hello", dw.buf.Bytes())
+ }
+}
+
+func TestDeferredWriter_FdZeroWhenUnsupported(t *testing.T) {
+ dw := &deferredWriter{w: &bytes.Buffer{}}
+ if got := dw.Fd(); got != 0 {
+ t.Fatalf("Fd() = %d, want 0", got)
+ }
+}