TestFocusSessionScriptMissReturnsFalse covers the case where ps found a match but iTerm2's AppleScript walked all sessions without finding the tty (e.g., the claude is in a non-iTerm tty, or the session was closed between ps and osascript).
(t *testing.T)
| 148 | // finding the tty (e.g., the claude is in a non-iTerm tty, or the |
| 149 | // session was closed between ps and osascript). |
| 150 | func TestFocusSessionScriptMissReturnsFalse(t *testing.T) { |
| 151 | const uuid = "11111111-2222-4333-8444-555555555555" |
| 152 | const psOutput = ` PID TTY COMMAND |
| 153 | 12345 ttys012 /Users/me/.bun/bin/claude --session-id 11111111-2222-4333-8444-555555555555 |
| 154 | ` |
| 155 | stubPS(t, psOutput, nil) |
| 156 | stubRunnerOutput(t, func(args []string) ([]byte, error) { |
| 157 | return []byte("miss"), nil |
| 158 | }) |
| 159 | |
| 160 | focused, err := FocusSession(uuid, "claude") |
| 161 | if focused || err != nil { |
| 162 | t.Errorf("got (%v, %v); want (false, nil) for script miss", focused, err) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | // TestFocusSessionPSError surfaces the error to the caller instead of |
| 167 | // silently treating it as "no match". The caller can then decide |
nothing calls this directly
no test coverage detected