summaryrefslogtreecommitdiff
path: root/internal/executor/gemini_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/executor/gemini_test.go')
-rw-r--r--internal/executor/gemini_test.go57
1 files changed, 50 insertions, 7 deletions
diff --git a/internal/executor/gemini_test.go b/internal/executor/gemini_test.go
index 363f0e9..073525c 100644
--- a/internal/executor/gemini_test.go
+++ b/internal/executor/gemini_test.go
@@ -24,9 +24,9 @@ func TestGeminiRunner_BuildArgs_BasicTask(t *testing.T) {
args := r.buildArgs(tk, &storage.Execution{ID: "test-exec"}, "/tmp/q.json")
- // Gemini CLI: instructions is the first positional arg
- if len(args) < 1 || args[0] != "fix the bug" {
- t.Errorf("expected instructions as first arg, got: %v", args)
+ // Gemini CLI: instructions passed via -p for non-interactive mode
+ if len(args) < 2 || args[0] != "-p" || args[1] != "fix the bug" {
+ t.Errorf("expected -p <instructions> as first args, got: %v", args)
}
argMap := make(map[string]bool)
@@ -52,17 +52,60 @@ func TestGeminiRunner_BuildArgs_PreamblePrepended(t *testing.T) {
args := r.buildArgs(tk, &storage.Execution{ID: "test-exec"}, "/tmp/q.json")
- if len(args) < 1 {
- t.Fatalf("expected at least 1 arg, got: %v", args)
+ if len(args) < 2 || args[0] != "-p" {
+ t.Fatalf("expected -p <instructions> as first args, got: %v", args)
}
- if !strings.HasPrefix(args[0], planningPreamble) {
+ if !strings.HasPrefix(args[1], planningPreamble) {
t.Errorf("instructions should start with planning preamble")
}
- if !strings.HasSuffix(args[0], "fix the bug") {
+ if !strings.HasSuffix(args[1], "fix the bug") {
t.Errorf("instructions should end with original instructions")
}
}
+func TestGeminiRunner_BuildArgs_IncludesYolo(t *testing.T) {
+ r := &GeminiRunner{}
+ tk := &task.Task{
+ Agent: task.AgentConfig{
+ Type: "gemini",
+ Instructions: "write a doc",
+ SkipPlanning: true,
+ },
+ }
+ args := r.buildArgs(tk, &storage.Execution{ID: "test-exec"}, "/tmp/q.json")
+ argMap := make(map[string]bool)
+ for _, a := range args {
+ argMap[a] = true
+ }
+ if !argMap["--yolo"] {
+ t.Errorf("expected --yolo in gemini args (enables all tools); got: %v", args)
+ }
+}
+
+func TestGeminiRunner_BuildArgs_IncludesPromptFlag(t *testing.T) {
+ r := &GeminiRunner{}
+ tk := &task.Task{
+ Agent: task.AgentConfig{
+ Type: "gemini",
+ Instructions: "do the thing",
+ SkipPlanning: true,
+ },
+ }
+ args := r.buildArgs(tk, &storage.Execution{ID: "test-exec"}, "/tmp/q.json")
+ // Instructions must be passed via -p/--prompt for non-interactive headless mode,
+ // not as a bare positional (which starts interactive mode).
+ found := false
+ for i, a := range args {
+ if (a == "-p" || a == "--prompt") && i+1 < len(args) && args[i+1] == "do the thing" {
+ found = true
+ break
+ }
+ }
+ if !found {
+ t.Errorf("expected instructions passed via -p/--prompt flag; got: %v", args)
+ }
+}
+
func TestGeminiRunner_Run_InaccessibleProjectDir_ReturnsError(t *testing.T) {
r := &GeminiRunner{
BinaryPath: "true", // would succeed if it ran