(t *testing.T)
| 141 | } |
| 142 | |
| 143 | func TestGeminiEngineExecution(t *testing.T) { |
| 144 | engine := NewGeminiEngine() |
| 145 | |
| 146 | t.Run("basic execution", func(t *testing.T) { |
| 147 | workflowData := &WorkflowData{ |
| 148 | Name: "test-workflow", |
| 149 | } |
| 150 | |
| 151 | steps := engine.GetExecutionSteps(workflowData, "/tmp/test.log") |
| 152 | require.Len(t, steps, 2, "Should generate settings step and execution step") |
| 153 | |
| 154 | // steps[0] = Write Gemini Config, steps[1] = Execute Gemini CLI |
| 155 | stepContent := strings.Join(steps[1], "\n") |
| 156 | |
| 157 | assert.Contains(t, stepContent, "name: Execute Gemini CLI", "Should have correct step name") |
| 158 | assert.Contains(t, stepContent, "id: agentic_execution", "Should have agentic_execution ID") |
| 159 | assert.Contains(t, stepContent, "gemini", "Should invoke gemini command") |
| 160 | assert.Contains(t, stepContent, "--yolo", "Should include --yolo flag for auto-approving tool executions") |
| 161 | assert.Contains(t, stepContent, "--skip-trust", "Should include --skip-trust flag to prevent workspace trust check from overriding --yolo") |
| 162 | assert.Contains(t, stepContent, "--output-format stream-json", "Should use streaming JSON output format") |
| 163 | assert.Contains(t, stepContent, `--prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"`, "Should include prompt argument with correct shell quoting") |
| 164 | assert.Contains(t, stepContent, "/tmp/test.log", "Should include log file") |
| 165 | assert.Contains(t, stepContent, "GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}", "Should set GEMINI_API_KEY env var") |
| 166 | }) |
| 167 | |
| 168 | t.Run("with model", func(t *testing.T) { |
| 169 | workflowData := &WorkflowData{ |
| 170 | Name: "test-workflow", |
| 171 | EngineConfig: &EngineConfig{ |
| 172 | Model: "gemini-1.5-pro", |
| 173 | }, |
| 174 | } |
| 175 | |
| 176 | steps := engine.GetExecutionSteps(workflowData, "/tmp/test.log") |
| 177 | require.Len(t, steps, 2, "Should generate settings step and execution step") |
| 178 | |
| 179 | stepContent := strings.Join(steps[1], "\n") |
| 180 | |
| 181 | // Model is passed via the native GEMINI_MODEL env var (not as a --model flag) |
| 182 | assert.Contains(t, stepContent, "GEMINI_MODEL: gemini-1.5-pro", "Should set GEMINI_MODEL env var") |
| 183 | assert.NotContains(t, stepContent, "--model gemini-1.5-pro", "Should not embed model in command") |
| 184 | }) |
| 185 | |
| 186 | t.Run("with MCP servers", func(t *testing.T) { |
| 187 | workflowData := &WorkflowData{ |
| 188 | Name: "test-workflow", |
| 189 | ParsedTools: &ToolsConfig{ |
| 190 | GitHub: &GitHubToolConfig{}, |
| 191 | }, |
| 192 | Tools: map[string]any{ |
| 193 | "github": map[string]any{}, |
| 194 | }, |
| 195 | } |
| 196 | |
| 197 | steps := engine.GetExecutionSteps(workflowData, "/tmp/test.log") |
| 198 | require.Len(t, steps, 2, "Should generate settings step and execution step") |
| 199 | |
| 200 | stepContent := strings.Join(steps[1], "\n") |
nothing calls this directly
no test coverage detected