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

94 lines
2.3 KiB
Go

package doctor
import (
"os"
"path/filepath"
"testing"
)
func TestCheckPendingMigrations(t *testing.T) {
tests := []struct {
name string
setup func(t *testing.T, dir string)
wantStatus string
wantMessage string
wantMigrations int
}{
{
name: "no beads directory",
setup: func(t *testing.T, dir string) {},
wantStatus: StatusOK,
wantMessage: "None required",
},
{
name: "empty beads directory",
setup: func(t *testing.T, dir string) {
if err := os.MkdirAll(filepath.Join(dir, ".beads"), 0755); err != nil {
t.Fatalf("failed to create .beads: %v", err)
}
},
wantStatus: StatusOK,
wantMessage: "None required",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tmpDir, err := os.MkdirTemp("", "bd-doctor-migration-*")
if err != nil {
t.Fatalf("failed to create temp dir: %v", err)
}
defer os.RemoveAll(tmpDir)
tt.setup(t, tmpDir)
check := CheckPendingMigrations(tmpDir)
if check.Status != tt.wantStatus {
t.Errorf("status = %q, want %q", check.Status, tt.wantStatus)
}
if tt.wantMessage != "" && check.Message != tt.wantMessage {
t.Errorf("message = %q, want %q", check.Message, tt.wantMessage)
}
if check.Category != CategoryMaintenance {
t.Errorf("category = %q, want %q", check.Category, CategoryMaintenance)
}
})
}
}
func TestDetectPendingMigrations(t *testing.T) {
t.Run("no beads directory returns empty", func(t *testing.T) {
tmpDir, err := os.MkdirTemp("", "bd-doctor-migration-*")
if err != nil {
t.Fatalf("failed to create temp dir: %v", err)
}
defer os.RemoveAll(tmpDir)
migrations := DetectPendingMigrations(tmpDir)
if len(migrations) != 0 {
t.Errorf("expected 0 migrations, got %d", len(migrations))
}
})
t.Run("empty beads directory returns empty", func(t *testing.T) {
tmpDir, err := os.MkdirTemp("", "bd-doctor-migration-*")
if err != nil {
t.Fatalf("failed to create temp dir: %v", err)
}
defer os.RemoveAll(tmpDir)
if err := os.MkdirAll(filepath.Join(tmpDir, ".beads"), 0755); err != nil {
t.Fatalf("failed to create .beads: %v", err)
}
migrations := DetectPendingMigrations(tmpDir)
if len(migrations) != 0 {
t.Errorf("expected 0 migrations, got %d", len(migrations))
}
})
}