(t *testing.T)
| 475 | } |
| 476 | |
| 477 | func TestEngineOutputCleanupWithMixedPaths(t *testing.T) { |
| 478 | // Test the cleanup logic directly with mixed paths to ensure proper filtering |
| 479 | var yaml strings.Builder |
| 480 | |
| 481 | // Simulate mixed output files: some in /tmp/gh-aw/, some in workspace |
| 482 | mockOutputFiles := []string{ |
| 483 | "/tmp/gh-aw/logs/debug.log", |
| 484 | "workspace-output/results.txt", |
| 485 | "/tmp/gh-aw/.cache/data.json", |
| 486 | "build/artifacts.zip", |
| 487 | } |
| 488 | |
| 489 | // Generate the engine output collection manually to test the logic |
| 490 | yaml.WriteString(" - name: Upload engine output files\n") |
| 491 | yaml.WriteString(" uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f\n") |
| 492 | yaml.WriteString(" with:\n") |
| 493 | yaml.WriteString(" name: agent_outputs\n") |
| 494 | yaml.WriteString(" path: |\n") |
| 495 | for _, file := range mockOutputFiles { |
| 496 | yaml.WriteString(" " + file + "\n") |
| 497 | } |
| 498 | yaml.WriteString(" if-no-files-found: ignore\n") |
| 499 | |
| 500 | // Add cleanup step using the same function as the actual implementation |
| 501 | cleanupYaml, hasCleanup := generateCleanupStep(mockOutputFiles) |
| 502 | if hasCleanup { |
| 503 | yaml.WriteString(cleanupYaml) |
| 504 | } |
| 505 | |
| 506 | result := yaml.String() |
| 507 | |
| 508 | // Verify that all files are included in the upload step |
| 509 | if !strings.Contains(result, "/tmp/gh-aw/logs/debug.log") { |
| 510 | t.Error("Expected /tmp/gh-aw/logs/debug.log to be included in upload step") |
| 511 | } |
| 512 | if !strings.Contains(result, "workspace-output/results.txt") { |
| 513 | t.Error("Expected workspace-output/results.txt to be included in upload step") |
| 514 | } |
| 515 | if !strings.Contains(result, "/tmp/gh-aw/.cache/data.json") { |
| 516 | t.Error("Expected /tmp/gh-aw/.cache/data.json to be included in upload step") |
| 517 | } |
| 518 | if !strings.Contains(result, "build/artifacts.zip") { |
| 519 | t.Error("Expected build/artifacts.zip to be included in upload step") |
| 520 | } |
| 521 | |
| 522 | // Verify that only workspace files are included in cleanup step |
| 523 | if strings.Contains(result, "rm -fr /tmp/gh-aw/logs/debug.log") { |
| 524 | t.Error("Cleanup step should NOT include 'rm -fr /tmp/gh-aw/logs/debug.log' command") |
| 525 | } |
| 526 | if strings.Contains(result, "rm -fr /tmp/gh-aw/.cache/data.json") { |
| 527 | t.Error("Cleanup step should NOT include 'rm -fr /tmp/gh-aw/.cache/data.json' command") |
| 528 | } |
| 529 | if !strings.Contains(result, "rm -fr workspace-output/results.txt") { |
| 530 | t.Error("Cleanup step should include 'rm -fr workspace-output/results.txt' command") |
| 531 | } |
| 532 | if !strings.Contains(result, "rm -fr build/artifacts.zip") { |
| 533 | t.Error("Cleanup step should include 'rm -fr build/artifacts.zip' command") |
| 534 | } |
nothing calls this directly
no test coverage detected