diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-16 03:10:55 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-16 03:10:55 +0200 |
| commit | 1fc1611fa99993cab5dc8bf0844183285296e3b2 (patch) | |
| tree | c5c9b8b5abac5b5d4c0d56ed90b0580184cc4383 /internal/tmuxedit/cursor_agent_test.go | |
| parent | 12090f25a3677291863dbb80277bdad3eaec0324 (diff) | |
Release v0.24.0v0.24.0
Bring unit test coverage from ~75% to 85.1% project-wide. All internal
packages now exceed 80% coverage. Refactored cmd entrypoints to extract
testable run() functions with injectable seams.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/tmuxedit/cursor_agent_test.go')
| -rw-r--r-- | internal/tmuxedit/cursor_agent_test.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/internal/tmuxedit/cursor_agent_test.go b/internal/tmuxedit/cursor_agent_test.go index 28d7fe1..867a55b 100644 --- a/internal/tmuxedit/cursor_agent_test.go +++ b/internal/tmuxedit/cursor_agent_test.go @@ -119,6 +119,55 @@ func TestCursorAgent_ClearInput(t *testing.T) { } } +func TestCursorAgent_ExtractPrompt_EmptyPattern(t *testing.T) { + // A cursorAgent with empty promptPat returns empty string + agent := &cursorAgent{baseAgent{promptPat: ""}} + got := agent.ExtractPrompt("│ → hello │") + if got != "" { + t.Errorf("expected empty for empty pattern, got %q", got) + } +} + +func TestCursorAgent_ExtractPrompt_InvalidRegex(t *testing.T) { + // A cursorAgent with invalid regex returns empty string + agent := &cursorAgent{baseAgent{promptPat: "[invalid"}} + got := agent.ExtractPrompt("│ → hello │") + if got != "" { + t.Errorf("expected empty for invalid regex, got %q", got) + } +} + +func TestCursorAgent_ClearInput_Disabled(t *testing.T) { + agent := &cursorAgent{baseAgent{clearFirst: false, clearKeys: "End BSpace*200"}} + err := agent.ClearInput("%1") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } +} + +func TestCursorAgent_ClearInput_EmptyKeys(t *testing.T) { + agent := &cursorAgent{baseAgent{clearFirst: true, clearKeys: ""}} + err := agent.ClearInput("%1") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } +} + +func TestCursorAgent_ClearInput_Error(t *testing.T) { + noSleep(t) + oldSend := sendKeys + defer func() { sendKeys = oldSend }() + sendKeys = func(string, ...string) error { + return fmt.Errorf("send failed") + } + + agent := newCursorAgent() + err := agent.ClearInput("%1") + if err == nil { + t.Fatal("expected error from sendClearSequence failure") + } +} + func TestCursorAgent_Detect(t *testing.T) { agent := newCursorAgent() tests := []struct { |
