(t *testing.T)
| 104 | } |
| 105 | |
| 106 | func TestCollectWorkflowFiles_TransitiveImports(t *testing.T) { |
| 107 | // Create a temporary directory for testing |
| 108 | tmpDir := t.TempDir() |
| 109 | |
| 110 | // Create base shared file |
| 111 | baseSharedPath := filepath.Join(tmpDir, "base-shared.md") |
| 112 | baseSharedContent := `# Base Shared Content |
| 113 | This is base shared content. |
| 114 | ` |
| 115 | err := os.WriteFile(baseSharedPath, []byte(baseSharedContent), 0644) |
| 116 | require.NoError(t, err) |
| 117 | |
| 118 | // Create intermediate shared file that imports base |
| 119 | intermediateSharedPath := filepath.Join(tmpDir, "intermediate-shared.md") |
| 120 | intermediateSharedContent := `--- |
| 121 | imports: |
| 122 | - base-shared.md |
| 123 | --- |
| 124 | # Intermediate Shared Content |
| 125 | This imports base shared. |
| 126 | ` |
| 127 | err = os.WriteFile(intermediateSharedPath, []byte(intermediateSharedContent), 0644) |
| 128 | require.NoError(t, err) |
| 129 | |
| 130 | // Create a workflow file that imports the intermediate file |
| 131 | workflowPath := filepath.Join(tmpDir, "test-workflow.md") |
| 132 | workflowContent := `--- |
| 133 | name: Test Workflow |
| 134 | on: workflow_dispatch |
| 135 | imports: |
| 136 | - intermediate-shared.md |
| 137 | --- |
| 138 | # Test Workflow |
| 139 | This workflow imports intermediate shared content. |
| 140 | ` |
| 141 | err = os.WriteFile(workflowPath, []byte(workflowContent), 0644) |
| 142 | require.NoError(t, err) |
| 143 | |
| 144 | // Create the corresponding lock file |
| 145 | lockFilePath := filepath.Join(tmpDir, "test-workflow.lock.yml") |
| 146 | lockContent := `name: Test Workflow |
| 147 | on: workflow_dispatch |
| 148 | ` |
| 149 | err = os.WriteFile(lockFilePath, []byte(lockContent), 0644) |
| 150 | require.NoError(t, err) |
| 151 | |
| 152 | // Test collecting files |
| 153 | files, err := collectWorkflowFiles(context.Background(), workflowPath, false, false) |
| 154 | require.NoError(t, err) |
| 155 | assert.Len(t, files, 4, "Should collect workflow, lock, and all transitive imports") |
| 156 | |
| 157 | // Check that all files are in the result |
| 158 | fileSet := make(map[string]bool) |
| 159 | for _, file := range files { |
| 160 | fileSet[file] = true |
| 161 | } |
| 162 | assert.True(t, fileSet[workflowPath], "Should include workflow .md file") |
| 163 | assert.True(t, fileSet[lockFilePath], "Should include lock .yml file") |
nothing calls this directly
no test coverage detected