gitgram/aitimemachine/beads/cmd/bd/migrate_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

69 lines
2.1 KiB
Go

//go:build cgo
package main
import (
"context"
"os"
"path/filepath"
"testing"
"github.com/steveyegge/beads/internal/storage/dolt"
)
// TestMigrateCommand removed: detectDatabases, getDBVersion, formatDBList, dbInfo
// were removed in Dolt-native pruning. Migration is now handled by bd init --from-jsonl.
// TestFormatDBList removed: formatDBList and dbInfo types were removed.
func TestMigrateRespectsConfigJSON(t *testing.T) {
t.Skip("SQLite-specific: Dolt backend always uses 'dolt' directory, not custom database filenames")
// Test that migrate respects custom database name from metadata.json
tmpDir := t.TempDir()
beadsDir := filepath.Join(tmpDir, ".beads")
if err := os.MkdirAll(beadsDir, 0750); err != nil {
t.Fatalf("Failed to create .beads directory: %v", err)
}
// Create metadata.json with custom database name
configPath := filepath.Join(beadsDir, "metadata.json")
configData := `{"database": "beady.db", "version": "0.21.1"}`
if err := os.WriteFile(configPath, []byte(configData), 0600); err != nil {
t.Fatalf("Failed to create metadata.json: %v", err)
}
// Create old database with custom name
oldDBPath := filepath.Join(beadsDir, "beady.db")
store, err := dolt.New(context.Background(), &dolt.Config{Path: oldDBPath})
if err != nil {
t.Skipf("skipping: Dolt server not available: %v", err)
}
ctx := context.Background()
if err := store.SetLocalMetadata(ctx, "bd_version", "0.21.1"); err != nil {
t.Fatalf("Failed to set version: %v", err)
}
_ = store.Close()
// Load config
cfg, err := loadOrCreateConfig(beadsDir)
if err != nil {
t.Fatalf("Failed to load config: %v", err)
}
// Verify config respects custom database name
if cfg.Database != "beady.db" {
t.Errorf("Expected database name 'beady.db', got %s", cfg.Database)
}
expectedPath := filepath.Join(beadsDir, "beady.db")
actualPath := cfg.DatabasePath(beadsDir)
if actualPath != expectedPath {
t.Errorf("Expected path %s, got %s", expectedPath, actualPath)
}
// Verify database exists at custom path
if _, err := os.Stat(actualPath); os.IsNotExist(err) {
t.Errorf("Database does not exist at custom path: %s", actualPath)
}
}