summaryrefslogtreecommitdiff
path: root/internal/tmuxedit/capture_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/tmuxedit/capture_test.go')
-rw-r--r--internal/tmuxedit/capture_test.go24
1 files changed, 9 insertions, 15 deletions
diff --git a/internal/tmuxedit/capture_test.go b/internal/tmuxedit/capture_test.go
index 40d0e98..c5a6605 100644
--- a/internal/tmuxedit/capture_test.go
+++ b/internal/tmuxedit/capture_test.go
@@ -6,15 +6,13 @@ import (
)
func TestCapturePane_Success(t *testing.T) {
- old := runCommand
- defer func() { runCommand = old }()
- runCommand = func(name string, args ...string) ([]byte, error) {
+ deps := tmuxEditDeps{runCommand: func(name string, args ...string) ([]byte, error) {
if name == "tmux" && len(args) >= 3 && args[0] == "capture-pane" {
return []byte("Claude Code v1.0\n> hello world\n"), nil
}
return nil, fmt.Errorf("unexpected: %s %v", name, args)
- }
- got, err := capturePane("%5")
+ }}
+ got, err := deps.capture("%5")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@@ -24,24 +22,20 @@ func TestCapturePane_Success(t *testing.T) {
}
func TestCapturePane_Error(t *testing.T) {
- old := runCommand
- defer func() { runCommand = old }()
- runCommand = func(string, ...string) ([]byte, error) {
+ deps := tmuxEditDeps{runCommand: func(string, ...string) ([]byte, error) {
return nil, fmt.Errorf("pane not found")
- }
- _, err := capturePane("%999")
+ }}
+ _, err := deps.capture("%999")
if err == nil {
t.Fatal("expected error for failed capture")
}
}
func TestCapturePane_EmptyContent(t *testing.T) {
- old := runCommand
- defer func() { runCommand = old }()
- runCommand = func(string, ...string) ([]byte, error) {
+ deps := tmuxEditDeps{runCommand: func(string, ...string) ([]byte, error) {
return []byte("\n\n"), nil
- }
- got, err := capturePane("%1")
+ }}
+ got, err := deps.capture("%1")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}