From 4ffb22e7f69f1c9c79b095d4e60bad3d97aac55b Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 18 Jun 2026 07:45:37 +0300 Subject: ik0 replace test seams with dependency injection --- internal/tmuxedit/cursor_agent_test.go | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'internal/tmuxedit/cursor_agent_test.go') 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") -- cgit v1.2.3