(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func TestCollectWorkflowFiles_WithImports(t *testing.T) { |
| 58 | // Create a temporary directory for testing |
| 59 | tmpDir := t.TempDir() |
| 60 | |
| 61 | // Create a shared file |
| 62 | sharedPath := filepath.Join(tmpDir, "shared.md") |
| 63 | sharedContent := `# Shared Content |
| 64 | This is shared content. |
| 65 | ` |
| 66 | err := os.WriteFile(sharedPath, []byte(sharedContent), 0644) |
| 67 | require.NoError(t, err) |
| 68 | |
| 69 | // Create a workflow file that imports the shared file |
| 70 | workflowPath := filepath.Join(tmpDir, "test-workflow.md") |
| 71 | workflowContent := `--- |
| 72 | name: Test Workflow |
| 73 | on: workflow_dispatch |
| 74 | imports: |
| 75 | - shared.md |
| 76 | --- |
| 77 | # Test Workflow |
| 78 | This workflow imports shared content. |
| 79 | ` |
| 80 | err = os.WriteFile(workflowPath, []byte(workflowContent), 0644) |
| 81 | require.NoError(t, err) |
| 82 | |
| 83 | // Create the corresponding lock file |
| 84 | lockFilePath := filepath.Join(tmpDir, "test-workflow.lock.yml") |
| 85 | lockContent := `name: Test Workflow |
| 86 | on: workflow_dispatch |
| 87 | ` |
| 88 | err = os.WriteFile(lockFilePath, []byte(lockContent), 0644) |
| 89 | require.NoError(t, err) |
| 90 | |
| 91 | // Test collecting files |
| 92 | files, err := collectWorkflowFiles(context.Background(), workflowPath, false, false) |
| 93 | require.NoError(t, err) |
| 94 | assert.Len(t, files, 3, "Should collect workflow, lock, and imported files") |
| 95 | |
| 96 | // Check that all files are in the result |
| 97 | fileSet := make(map[string]bool) |
| 98 | for _, file := range files { |
| 99 | fileSet[file] = true |
| 100 | } |
| 101 | assert.True(t, fileSet[workflowPath], "Should include workflow .md file") |
| 102 | assert.True(t, fileSet[lockFilePath], "Should include lock .yml file") |
| 103 | assert.True(t, fileSet[sharedPath], "Should include imported shared.md file") |
| 104 | } |
| 105 | |
| 106 | func TestCollectWorkflowFiles_TransitiveImports(t *testing.T) { |
| 107 | // Create a temporary directory for testing |
nothing calls this directly
no test coverage detected