diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-18 07:45:37 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-18 07:45:37 +0300 |
| commit | 4ffb22e7f69f1c9c79b095d4e60bad3d97aac55b (patch) | |
| tree | 2dc708cbb95975d34084eb5afd376871caa13e27 /internal/tmuxedit/cursor_agent_test.go | |
| parent | ece7dcfd232b780f5650326c8ac2379ca70387d4 (diff) | |
ik0 replace test seams with dependency injection
Diffstat (limited to 'internal/tmuxedit/cursor_agent_test.go')
| -rw-r--r-- | internal/tmuxedit/cursor_agent_test.go | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/internal/tmuxedit/cursor_agent_test.go b/internal/tmuxedit/cursor_agent_test.go index 867a55b..d81416b 100644 --- a/internal/tmuxedit/cursor_agent_test.go +++ b/internal/tmuxedit/cursor_agent_test.go @@ -82,24 +82,19 @@ func TestCursorAgent_ExtractPrompt(t *testing.T) { } func TestCursorAgent_ClearInput(t *testing.T) { - noSleep(t) var calls []string - oldSend := sendKeys - oldRepeat := sendRepeatedKey - defer func() { - sendKeys = oldSend - sendRepeatedKey = oldRepeat - }() - sendKeys = func(paneID string, keys ...string) error { + deps := noSleepDeps() + deps.sendKeys = func(paneID string, keys ...string) error { calls = append(calls, fmt.Sprintf("send:%s:%s", paneID, strings.Join(keys, ","))) return nil } - sendRepeatedKey = func(paneID, key string, count int) error { + deps.sendRepeatedKey = func(paneID, key string, count int) error { calls = append(calls, fmt.Sprintf("repeat:%s:%s*%d", paneID, key, count)) return nil } agent := newCursorAgent() + agent.deps = deps err := agent.ClearInput("%5") if err != nil { t.Fatalf("unexpected error: %v", err) @@ -154,14 +149,13 @@ func TestCursorAgent_ClearInput_EmptyKeys(t *testing.T) { } func TestCursorAgent_ClearInput_Error(t *testing.T) { - noSleep(t) - oldSend := sendKeys - defer func() { sendKeys = oldSend }() - sendKeys = func(string, ...string) error { + deps := noSleepDeps() + deps.sendKeys = func(string, ...string) error { return fmt.Errorf("send failed") } agent := newCursorAgent() + agent.deps = deps err := agent.ClearInput("%1") if err == nil { t.Fatal("expected error from sendClearSequence failure") |
