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/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/agent_test.go')
| -rw-r--r-- | internal/tmuxedit/agent_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/tmuxedit/agent_test.go b/internal/tmuxedit/agent_test.go index 3673d70..8bd1ad4 100644 --- a/internal/tmuxedit/agent_test.go +++ b/internal/tmuxedit/agent_test.go @@ -1,6 +1,8 @@ package tmuxedit import ( + "fmt" + "strings" "testing" ) @@ -86,6 +88,50 @@ func TestBaseAgent_ClearInput_Disabled(t *testing.T) { } } +func TestBaseAgent_ClearInput_EmptyKeys(t *testing.T) { + // clearFirst=true but no clearKeys should be a no-op + b := &baseAgent{clearFirst: true, clearKeys: ""} + err := b.ClearInput("%1") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } +} + +func TestBaseAgent_ClearInput_Enabled(t *testing.T) { + noSleep(t) + var calls []string + oldSend := sendKeys + defer func() { sendKeys = oldSend }() + sendKeys = func(paneID string, keys ...string) error { + calls = append(calls, fmt.Sprintf("send:%s:%s", paneID, strings.Join(keys, ","))) + return nil + } + + b := &baseAgent{clearFirst: true, clearKeys: "C-u"} + err := b.ClearInput("%2") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if len(calls) != 1 || calls[0] != "send:%2:C-u" { + t.Errorf("expected single C-u send call, got %v", calls) + } +} + +func TestBaseAgent_ClearInput_Error(t *testing.T) { + noSleep(t) + oldSend := sendKeys + defer func() { sendKeys = oldSend }() + sendKeys = func(string, ...string) error { + return fmt.Errorf("send failed") + } + + b := &baseAgent{clearFirst: true, clearKeys: "C-u"} + err := b.ClearInput("%1") + if err == nil { + t.Fatal("expected error from sendClearSequence failure") + } +} + func TestBaseAgent_ExtractPrompt_NoPattern(t *testing.T) { b := &baseAgent{} got := b.ExtractPrompt("some content") |
