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

Function TestCollectWorkflowFiles_WithImports

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

Source from the content-addressed store, hash-verified

55}
56
57func 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
64This 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 := `---
72name: Test Workflow
73on: workflow_dispatch
74imports:
75 - shared.md
76---
77# Test Workflow
78This 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
86on: 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
106func TestCollectWorkflowFiles_TransitiveImports(t *testing.T) {
107 // Create a temporary directory for testing

Callers

nothing calls this directly

Calls 2

collectWorkflowFilesFunction · 0.85
BackgroundMethod · 0.80

Tested by

no test coverage detected