(t *testing.T)
| 257 | } |
| 258 | |
| 259 | func TestConclusionJobIntegration(t *testing.T) { |
| 260 | // Test that the job is properly integrated with activation job outputs |
| 261 | compiler := NewCompiler() |
| 262 | statusCommentTrue := true |
| 263 | workflowData := &WorkflowData{ |
| 264 | Name: "Test Workflow", |
| 265 | AIReaction: "eyes", |
| 266 | StatusComment: &statusCommentTrue, // Explicitly enable status comments |
| 267 | SafeOutputs: &SafeOutputsConfig{ |
| 268 | AddComments: &AddCommentsConfig{ |
| 269 | BaseSafeOutputConfig: BaseSafeOutputConfig{ |
| 270 | Max: strPtr("1"), |
| 271 | }, |
| 272 | }, |
| 273 | }, |
| 274 | } |
| 275 | |
| 276 | // Build the conclusion job with sample safe output job names |
| 277 | safeOutputJobNames := []string{"add_comment", "missing_tool"} |
| 278 | job, err := compiler.buildConclusionJob(workflowData, string(constants.AgentJobName), safeOutputJobNames) |
| 279 | if err != nil { |
| 280 | t.Fatalf("Failed to build conclusion job: %v", err) |
| 281 | } |
| 282 | |
| 283 | if job == nil { |
| 284 | t.Fatal("Expected conclusion job to be created") |
| 285 | } |
| 286 | |
| 287 | // Convert job to YAML string for checking |
| 288 | jobYAML := strings.Join(job.Steps, "") |
| 289 | |
| 290 | // Check that environment variables reference activation outputs |
| 291 | if !strings.Contains(jobYAML, "needs.activation.outputs.comment_id") { |
| 292 | t.Error("Expected GH_AW_COMMENT_ID to reference activation.outputs.comment_id") |
| 293 | } |
| 294 | if !strings.Contains(jobYAML, "needs.activation.outputs.comment_repo") { |
| 295 | t.Error("Expected GH_AW_COMMENT_REPO to reference activation.outputs.comment_repo") |
| 296 | } |
| 297 | |
| 298 | // Check that agent result is referenced |
| 299 | if !strings.Contains(jobYAML, "needs.agent.result") { |
| 300 | t.Error("Expected GH_AW_AGENT_CONCLUSION to reference needs.agent.result") |
| 301 | } |
| 302 | |
| 303 | // Check expected conditions are present |
| 304 | if !strings.Contains(job.If, "always()") { |
| 305 | t.Error("Expected always() in conclusion condition") |
| 306 | } |
| 307 | if !strings.Contains(job.If, "needs.agent.result != 'skipped'") { |
| 308 | t.Error("Expected agent not skipped check in conclusion condition") |
| 309 | } |
| 310 | if !strings.Contains(job.If, "!(needs.add_comment.outputs.comment_id)") { |
| 311 | t.Error("Expected NOT add_comment.outputs.comment_id check in conclusion condition") |
| 312 | } |
| 313 | |
| 314 | // Verify job depends on the safe output jobs |
| 315 | for _, expectedNeed := range safeOutputJobNames { |
| 316 | found := slices.Contains(job.Needs, expectedNeed) |
nothing calls this directly
no test coverage detected