gitgram/aitimemachine/beads/cmd/bd/feedback_test.go
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

149 lines
4.0 KiB
Go

//go:build cgo
package main
import (
"testing"
"github.com/steveyegge/beads/internal/config"
"github.com/steveyegge/beads/internal/types"
)
const defaultTitleLength = 255
func TestFormatFeedbackID(t *testing.T) {
// Ensure config is initialized with defaults
config.ResetForTesting()
if err := config.Initialize(); err != nil {
t.Fatalf("config.Initialize: %v", err)
}
t.Cleanup(config.ResetForTesting)
t.Run("default shows full title", func(t *testing.T) {
got := formatFeedbackID("bd-abc", "Add user authentication")
want := "bd-abc — Add user authentication"
if got != want {
t.Errorf("got %q, want %q", got, want)
}
})
t.Run("empty title returns ID only", func(t *testing.T) {
got := formatFeedbackID("bd-abc", "")
if got != "bd-abc" {
t.Errorf("got %q, want %q", got, "bd-abc")
}
})
t.Run("title-length=0 hides title", func(t *testing.T) {
config.Set("output.title-length", 0)
t.Cleanup(func() { config.Set("output.title-length", defaultTitleLength) })
got := formatFeedbackID("bd-abc", "Add user authentication")
if got != "bd-abc" {
t.Errorf("got %q, want %q", got, "bd-abc")
}
})
t.Run("title-length truncates with ellipsis", func(t *testing.T) {
config.Set("output.title-length", 10)
t.Cleanup(func() { config.Set("output.title-length", defaultTitleLength) })
got := formatFeedbackID("bd-abc", "Add user authentication")
want := "bd-abc — Add user …"
if got != want {
t.Errorf("got %q, want %q", got, want)
}
})
t.Run("title within limit not truncated", func(t *testing.T) {
config.Set("output.title-length", 50)
t.Cleanup(func() { config.Set("output.title-length", defaultTitleLength) })
got := formatFeedbackID("bd-abc", "Short title")
want := "bd-abc — Short title"
if got != want {
t.Errorf("got %q, want %q", got, want)
}
})
}
func TestFormatFeedbackIDParen(t *testing.T) {
config.ResetForTesting()
if err := config.Initialize(); err != nil {
t.Fatalf("config.Initialize: %v", err)
}
t.Cleanup(config.ResetForTesting)
t.Run("default shows full title in parens", func(t *testing.T) {
got := formatFeedbackIDParen("bd-abc", "Write tests")
want := "bd-abc (Write tests)"
if got != want {
t.Errorf("got %q, want %q", got, want)
}
})
t.Run("empty title returns ID only", func(t *testing.T) {
got := formatFeedbackIDParen("bd-abc", "")
if got != "bd-abc" {
t.Errorf("got %q, want %q", got, "bd-abc")
}
})
t.Run("title-length=0 hides title", func(t *testing.T) {
config.Set("output.title-length", 0)
t.Cleanup(func() { config.Set("output.title-length", defaultTitleLength) })
got := formatFeedbackIDParen("bd-abc", "Write tests")
if got != "bd-abc" {
t.Errorf("got %q, want %q", got, "bd-abc")
}
})
}
func TestIssueTitleOrEmpty(t *testing.T) {
t.Run("nil issue returns empty", func(t *testing.T) {
got := issueTitleOrEmpty(nil)
if got != "" {
t.Errorf("got %q, want empty", got)
}
})
t.Run("non-nil issue returns title", func(t *testing.T) {
issue := &types.Issue{Title: "Fix bug"}
got := issueTitleOrEmpty(issue)
if got != "Fix bug" {
t.Errorf("got %q, want %q", got, "Fix bug")
}
})
}
func TestApplyTitleConfig(t *testing.T) {
config.ResetForTesting()
if err := config.Initialize(); err != nil {
t.Fatalf("config.Initialize: %v", err)
}
t.Cleanup(config.ResetForTesting)
t.Run("unicode truncation is rune-safe", func(t *testing.T) {
config.Set("output.title-length", 3)
t.Cleanup(func() { config.Set("output.title-length", defaultTitleLength) })
// 4-rune title: truncated to 2 runes + ellipsis (maxLen-1 reserves space for …)
got := applyTitleConfig("日本語文")
want := "日本…"
if got != want {
t.Errorf("got %q, want %q", got, want)
}
})
t.Run("negative values hide title", func(t *testing.T) {
config.Set("output.title-length", -1)
t.Cleanup(func() { config.Set("output.title-length", defaultTitleLength) })
got := applyTitleConfig("Hidden title")
if got != "" {
t.Errorf("got %q, want empty", got)
}
})
}