omarchy-send/internal/clipboard/clipboard_test.go
28allday 098c34c546 Clipboard send/copy, PIN for messages, and quiet stdlib logging
- Messages to a PIN-protected peer now prompt for the PIN and retry, like
  file sends (was a silent failure). SendMessage takes a pin argument and the
  TUI tracks whether a pending send is a message or files.
- Copy a received message to the clipboard with `y` (in the Messages tab or
  while reading one).
- Send the clipboard as a message with `v` on a device: it opens the compose
  box pre-filled with the clipboard text to review before sending.
- New internal/clipboard package shells out to wl-clipboard / xclip / xsel,
  and falls back to tmux's paste buffer when running inside tmux on a headless
  box (tmux load-buffer -w also reaches the outer clipboard via set-clipboard,
  which omaterm enables by default). No system tool -> "clipboard unavailable".
- Route the standard logger to the debug log (or discard) at startup so stray
  stdlib logging — e.g. net/http's "unsolicited response on idle channel"
  notice after a peer sends a late response — can't paint over the TUI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 22:06:24 +01:00

19 lines
588 B
Go

package clipboard
import (
"errors"
"testing"
)
// With no helpers reachable on PATH, both operations report ErrUnavailable
// rather than panicking or hanging. (We empty PATH instead of touching the real
// clipboard, so the test is safe to run anywhere.)
func TestUnavailableWithoutTools(t *testing.T) {
t.Setenv("PATH", "")
if _, err := Read(); !errors.Is(err, ErrUnavailable) {
t.Errorf("Read with no tools: got %v, want ErrUnavailable", err)
}
if err := Write("x"); !errors.Is(err, ErrUnavailable) {
t.Errorf("Write with no tools: got %v, want ErrUnavailable", err)
}
}