summaryrefslogtreecommitdiff
path: root/internal/executor/container_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/executor/container_test.go')
-rw-r--r--internal/executor/container_test.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/internal/executor/container_test.go b/internal/executor/container_test.go
index c56d1b2..15c147f 100644
--- a/internal/executor/container_test.go
+++ b/internal/executor/container_test.go
@@ -518,18 +518,23 @@ func TestContainerRunner_AuthError_SyncsAndRetries(t *testing.T) {
func TestContainerRunner_ClonesStoryBranch(t *testing.T) {
logger := slog.New(slog.NewTextHandler(io.Discard, nil))
- var cloneArgs []string
+ var checkoutArgs []string
runner := &ContainerRunner{
Logger: logger,
Image: "busybox",
Command: func(ctx context.Context, name string, arg ...string) *exec.Cmd {
if name == "git" && len(arg) > 0 && arg[0] == "clone" {
- cloneArgs = append([]string{}, arg...)
dir := arg[len(arg)-1]
os.MkdirAll(dir, 0755)
return exec.Command("true")
}
- // docker run fails so the test exits quickly
+ // Capture checkout calls: both "git checkout <branch>" and "git -C <dir> checkout <branch>"
+ for i, a := range arg {
+ if a == "checkout" {
+ checkoutArgs = append([]string{}, arg[i:]...)
+ break
+ }
+ }
if name == "docker" {
return exec.Command("sh", "-c", "exit 1")
}
@@ -548,19 +553,19 @@ func TestContainerRunner_ClonesStoryBranch(t *testing.T) {
runner.Run(context.Background(), tk, e)
os.RemoveAll(e.SandboxDir)
- // Assert git clone was called with --branch <branchName>
- if len(cloneArgs) < 3 {
- t.Fatalf("expected clone args, got %v", cloneArgs)
+ // Assert git checkout was called with the story branch name.
+ if len(checkoutArgs) == 0 {
+ t.Fatal("expected git checkout to be called for story branch, but it was not")
}
found := false
- for i, a := range cloneArgs {
- if a == "--branch" && i+1 < len(cloneArgs) && cloneArgs[i+1] == "story/my-feature" {
+ for _, a := range checkoutArgs {
+ if a == "story/my-feature" {
found = true
break
}
}
if !found {
- t.Errorf("expected git clone --branch story/my-feature, got args: %v", cloneArgs)
+ t.Errorf("expected git checkout story/my-feature, got args: %v", checkoutArgs)
}
}