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

Function TestCollectPackageIncludesRecursive

pkg/cli/packages_test.go:16–152  ·  view source on GitHub ↗

TestCollectPackageIncludesRecursive tests the recursive include dependency collection

(t *testing.T)

Source from the content-addressed store, hash-verified

14
15// TestCollectPackageIncludesRecursive tests the recursive include dependency collection
16func TestCollectPackageIncludesRecursive(t *testing.T) {
17 tests := []struct {
18 name string
19 content string
20 setupFiles map[string]string // file path -> content
21 baseDir string
22 expectedCount int
23 expectedPaths []string
24 expectedError bool
25 }{
26 {
27 name: "single include",
28 content: `---
29on: push
30---
31@include shared/common.md
32
33# My Workflow`,
34 setupFiles: map[string]string{
35 "shared/common.md": `# Common config`,
36 },
37 expectedCount: 1,
38 expectedPaths: []string{"shared/common.md"},
39 },
40 {
41 name: "optional include with missing file",
42 content: `@include? shared/optional.md
43# My Workflow`,
44 setupFiles: map[string]string{}, // no files
45 expectedCount: 1, // dependency is recorded even if file missing
46 expectedPaths: []string{"shared/optional.md"},
47 },
48 {
49 name: "include with section reference",
50 content: `@include shared/config.md#section
51# My Workflow`,
52 setupFiles: map[string]string{
53 "shared/config.md": `# Config`,
54 },
55 expectedCount: 1,
56 expectedPaths: []string{"shared/config.md"}, // section reference stripped
57 },
58 {
59 name: "nested includes",
60 content: `@include level1.md
61# Workflow`,
62 setupFiles: map[string]string{
63 "level1.md": `@include level2.md
64# Level 1`,
65 "level2.md": `# Level 2`,
66 },
67 expectedCount: 2,
68 expectedPaths: []string{"level1.md", "level2.md"},
69 },
70 {
71 name: "duplicate includes skipped",
72 content: `@include shared/common.md
73@include shared/common.md

Callers

nothing calls this directly

Calls 4

TempDirFunction · 0.92
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected