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>
46 lines
974 B
Go
46 lines
974 B
Go
package ticket_test
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"task/internal/ticket"
|
|
)
|
|
|
|
func TestFormatAndParseEditDocument(t *testing.T) {
|
|
doc := ticket.FormatEditDocument(ticket.Ticket{
|
|
Title: "Fix login",
|
|
Description: "Steps:\n\n1. repro\n2. patch",
|
|
})
|
|
if !strings.HasPrefix(doc, "# Fix login\n") {
|
|
t.Fatalf("format = %q", doc)
|
|
}
|
|
|
|
title, desc, err := ticket.ParseEditDocument(doc)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if title != "Fix login" {
|
|
t.Fatalf("title = %q", title)
|
|
}
|
|
if desc != "Steps:\n\n1. repro\n2. patch" {
|
|
t.Fatalf("desc = %q", desc)
|
|
}
|
|
}
|
|
|
|
func TestParseEditDocumentPlainTitle(t *testing.T) {
|
|
title, desc, err := ticket.ParseEditDocument("Plain title\n\nBody text")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if title != "Plain title" || desc != "Body text" {
|
|
t.Fatalf("got %q / %q", title, desc)
|
|
}
|
|
}
|
|
|
|
func TestParseEditDocumentEmpty(t *testing.T) {
|
|
if _, _, err := ticket.ParseEditDocument(" "); err == nil {
|
|
t.Fatal("expected error")
|
|
}
|
|
}
|