(t *testing.T)
| 226 | } |
| 227 | |
| 228 | func TestCrushEngineExecution(t *testing.T) { |
| 229 | engine := NewCrushEngine() |
| 230 | |
| 231 | t.Run("basic execution", func(t *testing.T) { |
| 232 | workflowData := &WorkflowData{ |
| 233 | Name: "test-workflow", |
| 234 | } |
| 235 | |
| 236 | steps := engine.GetExecutionSteps(workflowData, "/tmp/test.log") |
| 237 | require.Len(t, steps, 2, "Should generate config step and execution step") |
| 238 | |
| 239 | // steps[0] = Write Crush config, steps[1] = Execute Crush CLI |
| 240 | stepContent := strings.Join(steps[1], "\n") |
| 241 | |
| 242 | assert.Contains(t, stepContent, "name: Execute Crush CLI", "Should have correct step name") |
| 243 | assert.Contains(t, stepContent, "id: agentic_execution", "Should have agentic_execution ID") |
| 244 | assert.Contains(t, stepContent, "crush run", "Should invoke crush run command") |
| 245 | assert.Contains(t, stepContent, `"$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"`, "Should include prompt argument") |
| 246 | assert.Contains(t, stepContent, "/tmp/test.log", "Should include log file") |
| 247 | assert.Contains(t, stepContent, "OPENAI_API_KEY: ${{ secrets.COPILOT_GITHUB_TOKEN }}", "Should set OPENAI_API_KEY from COPILOT_GITHUB_TOKEN") |
| 248 | assert.Contains(t, stepContent, "NO_PROXY: localhost,127.0.0.1", "Should set NO_PROXY env var") |
| 249 | }) |
| 250 | |
| 251 | t.Run("basic execution with copilot-requests permission", func(t *testing.T) { |
| 252 | workflowData := &WorkflowData{ |
| 253 | Name: "test-workflow", |
| 254 | Permissions: "permissions:\n copilot-requests: write", |
| 255 | } |
| 256 | |
| 257 | steps := engine.GetExecutionSteps(workflowData, "/tmp/test.log") |
| 258 | require.Len(t, steps, 2, "Should generate config step and execution step") |
| 259 | |
| 260 | stepContent := strings.Join(steps[1], "\n") |
| 261 | assert.Contains(t, stepContent, "OPENAI_API_KEY: ${{ github.token }}", "Should set OPENAI_API_KEY from github.token when permissions.copilot-requests is write") |
| 262 | }) |
| 263 | |
| 264 | t.Run("with model", func(t *testing.T) { |
| 265 | workflowData := &WorkflowData{ |
| 266 | Name: "test-workflow", |
| 267 | EngineConfig: &EngineConfig{ |
| 268 | Model: "anthropic/claude-sonnet-4-20250514", |
| 269 | }, |
| 270 | } |
| 271 | |
| 272 | steps := engine.GetExecutionSteps(workflowData, "/tmp/test.log") |
| 273 | require.Len(t, steps, 2, "Should generate config step and execution step") |
| 274 | |
| 275 | stepContent := strings.Join(steps[1], "\n") |
| 276 | |
| 277 | // Model is passed via the native CRUSH_MODEL env var |
| 278 | assert.Contains(t, stepContent, "CRUSH_MODEL: anthropic/claude-sonnet-4-20250514", "Should set CRUSH_MODEL env var") |
| 279 | }) |
| 280 | |
| 281 | t.Run("without model no model env var", func(t *testing.T) { |
| 282 | workflowData := &WorkflowData{ |
| 283 | Name: "test-workflow", |
| 284 | } |
| 285 |
nothing calls this directly
no test coverage detected