MCPcopy Create free account
hub / github.com/github/gh-aw / TestCollectWorkflowFiles_TransitiveImports

Function TestCollectWorkflowFiles_TransitiveImports

pkg/cli/run_push_test.go:106–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

104}
105
106func 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
113This 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 := `---
121imports:
122 - base-shared.md
123---
124# Intermediate Shared Content
125This 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 := `---
133name: Test Workflow
134on: workflow_dispatch
135imports:
136 - intermediate-shared.md
137---
138# Test Workflow
139This 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
147on: 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")

Callers

nothing calls this directly

Calls 2

collectWorkflowFilesFunction · 0.85
BackgroundMethod · 0.80

Tested by

no test coverage detected