summaryrefslogtreecommitdiff
path: root/internal/ui/table_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-22 14:25:14 +0300
committerPaul Buetow <paul@buetow.org>2026-06-22 14:25:14 +0300
commita1407cd9c960da7cb7e13b37ec444590319b8908 (patch)
tree007b9f796e05c0043292afedb89c8b6c6f723bd0 /internal/ui/table_test.go
parent6fafae88fd8cfcb972c1ed98d8eb591a910043d2 (diff)
Fix description editor ExecProcess flow for nq0
Diffstat (limited to 'internal/ui/table_test.go')
-rw-r--r--internal/ui/table_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/internal/ui/table_test.go b/internal/ui/table_test.go
index f255fe3..bfd866d 100644
--- a/internal/ui/table_test.go
+++ b/internal/ui/table_test.go
@@ -203,6 +203,48 @@ func TestHandleDescEditDoneUpdatesDescriptionAndRemovesTempFile(t *testing.T) {
}
}
+func TestEditDescriptionCmdPreparesLaunchWithoutRunningEditor(t *testing.T) {
+ tmp := t.TempDir()
+ editorLog := filepath.Join(tmp, "editor.log")
+ editorPath := filepath.Join(tmp, "editor")
+ editorScript := "#!/bin/sh\n" +
+ "printf ran > " + editorLog + "\n"
+ if err := os.WriteFile(editorPath, []byte(editorScript), 0o755); err != nil {
+ t.Fatal(err)
+ }
+
+ origEditor := os.Getenv("EDITOR")
+ os.Setenv("EDITOR", editorPath)
+ t.Cleanup(func() { os.Setenv("EDITOR", origEditor) })
+
+ cmd := editDescriptionCmd("old description")
+ msg := cmd()
+
+ launchMsg, ok := msg.(descEditLaunchMsg)
+ if !ok {
+ t.Fatalf("editDescriptionCmd returned %T, want descEditLaunchMsg", msg)
+ }
+ defer func() { _ = os.Remove(launchMsg.tempFile) }()
+
+ if _, err := os.Stat(editorLog); !os.IsNotExist(err) {
+ t.Fatalf("editor was run during temp-file preparation: %v", err)
+ }
+
+ content, err := os.ReadFile(launchMsg.tempFile)
+ if err != nil {
+ t.Fatalf("read temp description: %v", err)
+ }
+ if string(content) != "old description" {
+ t.Fatalf("temp description = %q, want %q", content, "old description")
+ }
+
+ m := Model{}
+ _, launchCmd := (&m).Update(launchMsg)
+ if launchCmd == nil {
+ t.Fatalf("descEditLaunchMsg did not return an editor launch command")
+ }
+}
+
func TestPrepareDescriptionTempFileRemovesTempFileOnWriteError(t *testing.T) {
tmp := t.TempDir()
tempFile := filepath.Join(tmp, "desc.txt")