(t *testing.T)
| 251 | } |
| 252 | |
| 253 | func TestCompileWorkflowWithTracking_SharedActions(t *testing.T) { |
| 254 | // Create a temporary directory for testing |
| 255 | tempDir, err := os.MkdirTemp("", "shared-actions-test") |
| 256 | if err != nil { |
| 257 | t.Fatalf("Failed to create temp dir: %v", err) |
| 258 | } |
| 259 | defer os.RemoveAll(tempDir) |
| 260 | |
| 261 | // Initialize git repository in temp directory |
| 262 | gitCmd := []string{"git", "init"} |
| 263 | if err := runCommandInDir(gitCmd, tempDir); err != nil { |
| 264 | t.Skipf("Skipping test - git not available or failed to init: %v", err) |
| 265 | } |
| 266 | |
| 267 | // Change to temp directory |
| 268 | oldWd, _ := os.Getwd() |
| 269 | defer func() { |
| 270 | _ = os.Chdir(oldWd) |
| 271 | }() |
| 272 | if err := os.Chdir(tempDir); err != nil { |
| 273 | t.Fatalf("Failed to change to temp directory: %v", err) |
| 274 | } |
| 275 | |
| 276 | // Test 1: Workflow WITH reaction should create shared action |
| 277 | workflowWithReaction := `--- |
| 278 | name: Test Workflow With Reaction |
| 279 | on: |
| 280 | push: {} |
| 281 | reaction: heart |
| 282 | --- |
| 283 | |
| 284 | This is a test workflow. |
| 285 | |
| 286 | ## Job: test |
| 287 | |
| 288 | This uses reaction. |
| 289 | ` |
| 290 | |
| 291 | workflowFileWithReaction := filepath.Join(tempDir, "test-workflow-with-reaction.md") |
| 292 | if err := os.WriteFile(workflowFileWithReaction, []byte(workflowWithReaction), 0644); err != nil { |
| 293 | t.Fatalf("Failed to create workflow file: %v", err) |
| 294 | } |
| 295 | |
| 296 | // Create file tracker |
| 297 | tracker := NewFileTracker() |
| 298 | |
| 299 | // Compile the workflow with tracking |
| 300 | if err := compileWorkflowWithTracking(context.Background(), workflowFileWithReaction, false, false, "", tracker); err != nil { |
| 301 | t.Fatalf("Failed to compile workflow: %v", err) |
| 302 | } |
| 303 | |
| 304 | // Check that shared action files are tracked |
| 305 | allFiles := append(tracker.CreatedFiles, tracker.ModifiedFiles...) |
| 306 | |
| 307 | // Should track the lock file |
| 308 | lockFile := filepath.Join(tempDir, "test-workflow-with-reaction.lock.yml") |
| 309 | found := slices.Contains(allFiles, lockFile) |
| 310 | if !found { |
nothing calls this directly
no test coverage detected