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

117 lines
3.2 KiB
Go

package doctor
import (
"os"
"os/exec"
"path/filepath"
"testing"
)
func TestCheckBeadsRole_NotConfigured(t *testing.T) {
// Create a temp directory with git init but no beads.role config
tmpDir := newGitRepo(t)
// Check role - should return warning since not configured
check := CheckBeadsRole(tmpDir)
if check.Status != StatusWarning {
t.Errorf("expected status %s, got %s", StatusWarning, check.Status)
}
if check.Name != "Role Configuration" {
t.Errorf("expected name 'Role Configuration', got %q", check.Name)
}
if check.Fix != "git config beads.role maintainer" {
t.Errorf("expected fix 'git config beads.role maintainer', got %q", check.Fix)
}
}
func TestCheckBeadsRole_Maintainer(t *testing.T) {
tmpDir := newGitRepo(t)
// Set beads.role to maintainer
cmd := exec.Command("git", "config", "beads.role", "maintainer")
cmd.Dir = tmpDir
if err := cmd.Run(); err != nil {
t.Fatalf("git config failed: %v", err)
}
check := CheckBeadsRole(tmpDir)
if check.Status != StatusOK {
t.Errorf("expected status %s, got %s", StatusOK, check.Status)
}
if check.Message != "Configured as maintainer" {
t.Errorf("expected message 'Configured as maintainer', got %q", check.Message)
}
}
func TestCheckBeadsRole_Contributor(t *testing.T) {
tmpDir := newGitRepo(t)
// Set beads.role to contributor
cmd := exec.Command("git", "config", "beads.role", "contributor")
cmd.Dir = tmpDir
if err := cmd.Run(); err != nil {
t.Fatalf("git config failed: %v", err)
}
check := CheckBeadsRole(tmpDir)
if check.Status != StatusOK {
t.Errorf("expected status %s, got %s", StatusOK, check.Status)
}
if check.Message != "Configured as contributor" {
t.Errorf("expected message 'Configured as contributor', got %q", check.Message)
}
}
func TestCheckBeadsRole_InvalidValue(t *testing.T) {
tmpDir := newGitRepo(t)
// Set beads.role to an invalid value
cmd := exec.Command("git", "config", "beads.role", "admin")
cmd.Dir = tmpDir
if err := cmd.Run(); err != nil {
t.Fatalf("git config failed: %v", err)
}
check := CheckBeadsRole(tmpDir)
if check.Status != StatusWarning {
t.Errorf("expected status %s, got %s", StatusWarning, check.Status)
}
if check.Fix != "bd init" {
t.Errorf("expected fix 'bd init', got %q", check.Fix)
}
}
func TestCheckBeadsRole_NotGitRepo(t *testing.T) {
tmpDir, err := os.MkdirTemp("", "beads-role-test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpDir)
// Don't initialize git - just a plain directory
check := CheckBeadsRole(tmpDir)
// Should return OK/N/A since we're not in a git repo — the role may
// be correctly configured in a worktree (e.g., rig roots use .repo.git).
if check.Status != StatusOK {
t.Errorf("expected status %s, got %s", StatusOK, check.Status)
}
if check.Message != "N/A (not a git repository)" {
t.Errorf("expected message 'N/A (not a git repository)', got %q", check.Message)
}
}
func TestCheckBeadsRole_NonexistentPath(t *testing.T) {
// Test with a path that doesn't exist — git will report "not a git repository"
check := CheckBeadsRole(filepath.Join(os.TempDir(), "nonexistent-beads-test-dir"))
// Should return OK/N/A since the path is not a git repository
if check.Status != StatusOK {
t.Errorf("expected status %s, got %s", StatusOK, check.Status)
}
}