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

74 lines
3.0 KiB
Go

package dolt
import (
"context"
"strings"
"testing"
)
// TestBootstrapFromRemoteWithDB_RejectsEmptyDatabase verifies that
// BootstrapFromRemoteWithDB returns an error when called with an
// empty database name. Callers should use cfg.GetDoltDatabase() which
// applies the fallback chain (env var -> config -> default). A silent
// fallback to "beads" here previously masked misconfiguration (GH#3029).
func TestBootstrapFromRemoteWithDB_RejectsEmptyDatabase(t *testing.T) {
doltDir := t.TempDir()
_, err := BootstrapFromRemoteWithDB(context.Background(), doltDir, "file:///dev/null", "")
if err == nil {
t.Fatal("expected error for empty database name, got nil")
}
if !strings.Contains(err.Error(), "database name must not be empty") {
t.Errorf("unexpected error message: %v", err)
}
}
// TestBootstrapFromRemoteWithDB_RejectsWhitespaceDatabase verifies that
// whitespace-only database names are also rejected (defense-in-depth).
func TestBootstrapFromRemoteWithDB_RejectsWhitespaceDatabase(t *testing.T) {
doltDir := t.TempDir()
_, err := BootstrapFromRemoteWithDB(context.Background(), doltDir, "file:///dev/null", " ")
if err == nil {
t.Fatal("expected error for whitespace-only database name, got nil")
}
if !strings.Contains(err.Error(), "database name must not be empty") {
t.Errorf("unexpected error message: %v", err)
}
}
// TestBootstrapFromRemote_UsesDefaultDatabase verifies that the
// convenience wrapper BootstrapFromRemote explicitly passes the
// default database name rather than an empty string.
func TestBootstrapFromRemote_UsesDefaultDatabase(t *testing.T) {
// Create a doltDir that already contains a database so the function
// returns early (skips clone) without needing the dolt CLI.
doltDir := t.TempDir()
// BootstrapFromRemote should not error with "database name must not be empty"
// because it passes configfile.DefaultDoltDatabase explicitly.
// It will return false (skipped) because doltExists returns false for an
// empty dir, then it will fail trying to run dolt clone — but the error
// should be about dolt CLI, not about empty database name.
_, err := BootstrapFromRemote(context.Background(), doltDir, "file:///dev/null")
if err != nil && strings.Contains(err.Error(), "database name must not be empty") {
t.Fatal("BootstrapFromRemote should pass an explicit database name, not empty string")
}
// Any other error (dolt CLI not found, clone failure) is fine — we only care
// that the empty-database guard didn't fire.
}
// TestBootstrapFromGitRemoteWithDB_DeprecatedWrapper verifies that the
// deprecated BootstrapFromGitRemoteWithDB wrapper delegates correctly.
func TestBootstrapFromGitRemoteWithDB_DeprecatedWrapper(t *testing.T) {
doltDir := t.TempDir()
_, err := BootstrapFromGitRemoteWithDB(context.Background(), doltDir, "file:///dev/null", "")
if err == nil {
t.Fatal("expected error for empty database name, got nil")
}
if !strings.Contains(err.Error(), "database name must not be empty") {
t.Errorf("unexpected error message: %v", err)
}
}