Add comprehensive tests for 3-way merge functionality

- Added merge_test.go with 797 lines of test coverage
- Tests for field merging, dependency merging, timestamp handling
- Tests for deletion detection and conflict generation
- Integration tests for merge driver auto-config in bd init
- Test helpers for git repository setup

Closes bd-kazt

All tests pass: go test ./internal/merge/... -v

Amp-Thread-ID: https://ampcode.com/threads/T-f0fe7c4c-13e7-486b-b073-fc64b81eeb4b
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-11-06 15:51:40 -08:00
parent f475c13064
commit 14b2d3431f
3 changed files with 940 additions and 0 deletions

View File

@@ -3,7 +3,9 @@ package main
import (
"context"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
"github.com/steveyegge/beads/internal/storage/sqlite"
@@ -66,3 +68,21 @@ func openExistingTestDB(t *testing.T, dbPath string) (*sqlite.SQLiteStorage, err
t.Helper()
return sqlite.New(dbPath)
}
// runCommandInDir runs a command in the specified directory
func runCommandInDir(dir string, name string, args ...string) error {
cmd := exec.Command(name, args...)
cmd.Dir = dir
return cmd.Run()
}
// runCommandInDirWithOutput runs a command in the specified directory and returns its output
func runCommandInDirWithOutput(dir string, name string, args ...string) (string, error) {
cmd := exec.Command(name, args...)
cmd.Dir = dir
output, err := cmd.Output()
if err != nil {
return "", err
}
return strings.TrimSpace(string(output)), nil
}