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>
72 lines
1.8 KiB
Go
72 lines
1.8 KiB
Go
package fix
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"path/filepath"
|
|
"syscall"
|
|
"testing"
|
|
)
|
|
|
|
func TestMoveFile_EXDEV_FallsBackToCopy(t *testing.T) {
|
|
root := t.TempDir()
|
|
src := filepath.Join(root, "src.txt")
|
|
dst := filepath.Join(root, "dst.txt")
|
|
if err := os.WriteFile(src, []byte("hello"), 0644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
oldRename := renameFile
|
|
defer func() { renameFile = oldRename }()
|
|
renameFile = func(oldpath, newpath string) error {
|
|
return &os.LinkError{Op: "rename", Old: oldpath, New: newpath, Err: syscall.EXDEV}
|
|
}
|
|
|
|
if err := moveFile(src, dst); err != nil {
|
|
t.Fatalf("moveFile failed: %v", err)
|
|
}
|
|
if _, err := os.Stat(src); !os.IsNotExist(err) {
|
|
t.Fatalf("expected src to be removed, stat err=%v", err)
|
|
}
|
|
data, err := os.ReadFile(dst)
|
|
if err != nil {
|
|
t.Fatalf("read dst: %v", err)
|
|
}
|
|
if string(data) != "hello" {
|
|
t.Fatalf("dst contents=%q", string(data))
|
|
}
|
|
}
|
|
|
|
func TestMoveFile_EXDEV_CopyFails_LeavesSource(t *testing.T) {
|
|
root := t.TempDir()
|
|
src := filepath.Join(root, "src.txt")
|
|
dst := filepath.Join(root, "dst.txt")
|
|
if err := os.WriteFile(src, []byte("hello"), 0644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
oldRename := renameFile
|
|
oldOpenRW := openFileRW
|
|
defer func() {
|
|
renameFile = oldRename
|
|
openFileRW = oldOpenRW
|
|
}()
|
|
renameFile = func(oldpath, newpath string) error {
|
|
return &os.LinkError{Op: "rename", Old: oldpath, New: newpath, Err: syscall.EXDEV}
|
|
}
|
|
openFileRW = func(name string, flag int, perm os.FileMode) (*os.File, error) {
|
|
return nil, &os.PathError{Op: "open", Path: name, Err: syscall.ENOSPC}
|
|
}
|
|
|
|
err := moveFile(src, dst)
|
|
if err == nil {
|
|
t.Fatalf("expected error")
|
|
}
|
|
if !errors.Is(err, syscall.ENOSPC) {
|
|
t.Fatalf("expected ENOSPC, got %v", err)
|
|
}
|
|
if _, err := os.Stat(src); err != nil {
|
|
t.Fatalf("expected src to remain, stat err=%v", err)
|
|
}
|
|
}
|