fix(tests): create main branch after initial commit for worktree tests
ci / test (push) Failing after 37s
ci / test (push) Failing after 37s
Tests were failing because git worktree add -b branch worktree origin/main requires origin/main to exist. Now all test setups create main branch after initial commit so cloned repos have the expected branch.
This commit is contained in:
@@ -47,6 +47,12 @@ func TestGitCloneAndFetch(t *testing.T) {
|
||||
t.Fatalf("git commit failed: %v", err)
|
||||
}
|
||||
|
||||
// Create main branch (required for worktree operations)
|
||||
cmd = exec.Command("git", "-C", sourceDir, "checkout", "-b", "main")
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git checkout -b main failed: %v", err)
|
||||
}
|
||||
|
||||
// Test clone into empty path
|
||||
ctx := context.Background()
|
||||
err := action.CloneRepoActivity(ctx, action.CloneRepoInput{
|
||||
@@ -124,6 +130,12 @@ func TestGitWorktreeAdd(t *testing.T) {
|
||||
t.Fatalf("git commit failed: %v", err)
|
||||
}
|
||||
|
||||
// Create main branch (required for worktree operations)
|
||||
cmd = exec.Command("git", "-C", sourceDir, "checkout", "-b", "main")
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git checkout -b main failed: %v", err)
|
||||
}
|
||||
|
||||
// Clone the repo
|
||||
ctx := context.Background()
|
||||
err := action.CloneRepoActivity(ctx, action.CloneRepoInput{
|
||||
@@ -186,6 +198,12 @@ func TestGitCommit(t *testing.T) {
|
||||
t.Fatalf("git commit failed: %v", err)
|
||||
}
|
||||
|
||||
// Create main branch (required for worktree operations)
|
||||
cmd = exec.Command("git", "-C", sourceDir, "checkout", "-b", "main")
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git checkout -b main failed: %v", err)
|
||||
}
|
||||
|
||||
// Clone the repo
|
||||
ctx := context.Background()
|
||||
err := action.CloneRepoActivity(ctx, action.CloneRepoInput{
|
||||
|
||||
Reference in New Issue
Block a user