(workflow) add simple harness workflow for manual testing
This commit is contained in:
+36
-20
@@ -91,40 +91,48 @@ func TestGitCloneAndFetch(t *testing.T) {
|
||||
|
||||
func TestGitWorktreeAdd(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
sourceDir := filepath.Join(tmpDir, "source")
|
||||
repoDir := filepath.Join(tmpDir, "repo")
|
||||
|
||||
// Initialize repo
|
||||
if err := os.MkdirAll(repoDir, 0755); err != nil {
|
||||
t.Fatalf("failed to create repo dir: %v", err)
|
||||
// Initialize source repo
|
||||
if err := os.MkdirAll(sourceDir, 0755); err != nil {
|
||||
t.Fatalf("failed to create source dir: %v", err)
|
||||
}
|
||||
|
||||
cmd := exec.Command("git", "init", repoDir)
|
||||
cmd := exec.Command("git", "init", sourceDir)
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git init failed: %v", err)
|
||||
}
|
||||
|
||||
// Configure git user
|
||||
exec.Command("git", "-C", repoDir, "config", "user.email", "[email protected]").Run()
|
||||
exec.Command("git", "-C", repoDir, "config", "user.name", "Test User").Run()
|
||||
exec.Command("git", "-C", sourceDir, "config", "user.email", "[email protected]").Run()
|
||||
exec.Command("git", "-C", sourceDir, "config", "user.name", "Test User").Run()
|
||||
|
||||
// Create initial commit
|
||||
testFile := filepath.Join(repoDir, "test.txt")
|
||||
testFile := filepath.Join(sourceDir, "test.txt")
|
||||
if err := os.WriteFile(testFile, []byte("test"), 0644); err != nil {
|
||||
t.Fatalf("failed to create test file: %v", err)
|
||||
}
|
||||
|
||||
cmd = exec.Command("git", "-C", repoDir, "add", "test.txt")
|
||||
cmd = exec.Command("git", "-C", sourceDir, "add", "test.txt")
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git add failed: %v", err)
|
||||
}
|
||||
|
||||
cmd = exec.Command("git", "-C", repoDir, "commit", "-m", "initial")
|
||||
cmd = exec.Command("git", "-C", sourceDir, "commit", "-m", "initial")
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git commit failed: %v", err)
|
||||
}
|
||||
|
||||
// Test worktree add
|
||||
// Clone the repo
|
||||
ctx := context.Background()
|
||||
err := action.CloneRepoActivity(ctx, action.CloneRepoInput{
|
||||
RemoteURL: sourceDir,
|
||||
TargetRepoPath: repoDir,
|
||||
})
|
||||
assert.NoError(t, err, "clone should succeed")
|
||||
|
||||
// Test worktree add
|
||||
worktreePath, err := action.GitWorktreeAddActivity(ctx, action.GitWorktreeAddInput{
|
||||
RepoPath: repoDir,
|
||||
TaskID: "T0.1",
|
||||
@@ -145,40 +153,48 @@ func TestGitWorktreeAdd(t *testing.T) {
|
||||
|
||||
func TestGitCommit(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
sourceDir := filepath.Join(tmpDir, "source")
|
||||
repoDir := filepath.Join(tmpDir, "repo")
|
||||
|
||||
// Initialize repo
|
||||
if err := os.MkdirAll(repoDir, 0755); err != nil {
|
||||
t.Fatalf("failed to create repo dir: %v", err)
|
||||
// Initialize source repo
|
||||
if err := os.MkdirAll(sourceDir, 0755); err != nil {
|
||||
t.Fatalf("failed to create source dir: %v", err)
|
||||
}
|
||||
|
||||
cmd := exec.Command("git", "init", repoDir)
|
||||
cmd := exec.Command("git", "init", sourceDir)
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git init failed: %v", err)
|
||||
}
|
||||
|
||||
// Configure git user
|
||||
exec.Command("git", "-C", repoDir, "config", "user.email", "[email protected]").Run()
|
||||
exec.Command("git", "-C", repoDir, "config", "user.name", "Test User").Run()
|
||||
exec.Command("git", "-C", sourceDir, "config", "user.email", "[email protected]").Run()
|
||||
exec.Command("git", "-C", sourceDir, "config", "user.name", "Test User").Run()
|
||||
|
||||
// Create initial commit
|
||||
testFile := filepath.Join(repoDir, "test.txt")
|
||||
testFile := filepath.Join(sourceDir, "test.txt")
|
||||
if err := os.WriteFile(testFile, []byte("test"), 0644); err != nil {
|
||||
t.Fatalf("failed to create test file: %v", err)
|
||||
}
|
||||
|
||||
cmd = exec.Command("git", "-C", repoDir, "add", "test.txt")
|
||||
cmd = exec.Command("git", "-C", sourceDir, "add", "test.txt")
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git add failed: %v", err)
|
||||
}
|
||||
|
||||
cmd = exec.Command("git", "-C", repoDir, "commit", "-m", "initial")
|
||||
cmd = exec.Command("git", "-C", sourceDir, "commit", "-m", "initial")
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git commit failed: %v", err)
|
||||
}
|
||||
|
||||
// Create a worktree
|
||||
// Clone the repo
|
||||
ctx := context.Background()
|
||||
err := action.CloneRepoActivity(ctx, action.CloneRepoInput{
|
||||
RemoteURL: sourceDir,
|
||||
TargetRepoPath: repoDir,
|
||||
})
|
||||
assert.NoError(t, err, "clone should succeed")
|
||||
|
||||
// Create a worktree
|
||||
worktreePath, err := action.GitWorktreeAddActivity(ctx, action.GitWorktreeAddInput{
|
||||
RepoPath: repoDir,
|
||||
TaskID: "T0.1",
|
||||
|
||||
Reference in New Issue
Block a user