Charm-based CLI with JSON persistence, status/list filters, external editor editing, command-history undo/redo, and glamour markdown without AutoStyle OSC hangs. Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
714 B
Go
35 lines
714 B
Go
package ticket_test
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"testing"
|
|
|
|
"task/internal/ticket"
|
|
)
|
|
|
|
func TestResolveEditorPrefersEnv(t *testing.T) {
|
|
t.Setenv("EDITOR", "custom-ed")
|
|
t.Setenv("VISUAL", "visual-ed")
|
|
if got := ticket.ResolveEditor(); got != "custom-ed" {
|
|
t.Fatalf("got %q, want custom-ed", got)
|
|
}
|
|
}
|
|
|
|
func TestResolveEditorFallsBackToNvim(t *testing.T) {
|
|
t.Setenv("EDITOR", "")
|
|
t.Setenv("VISUAL", "")
|
|
got := ticket.ResolveEditor()
|
|
if _, err := exec.LookPath("nvim"); err == nil {
|
|
if got != "nvim" {
|
|
t.Fatalf("got %q, want nvim when available", got)
|
|
}
|
|
return
|
|
}
|
|
// Without nvim, accept vim/vi.
|
|
if got != "vim" && got != "vi" {
|
|
t.Fatalf("got unexpected fallback %q", got)
|
|
}
|
|
_ = os.Environ()
|
|
}
|