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

Function TestMultipleImportsWithError

pkg/parser/import_error_integration_test.go:69–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func TestMultipleImportsWithError(t *testing.T) {
70 tempDir := testutil.TempDir(t, "import-error-*")
71
72 // Create one valid import file
73 validImportPath := filepath.Join(tempDir, "valid.md")
74 validImportContent := `---
75on: push
76tools:
77 bash: {}
78---
79`
80 if err := os.WriteFile(validImportPath, []byte(validImportContent), 0644); err != nil {
81 t.Fatalf("Failed to write valid import file: %v", err)
82 }
83
84 // Create a workflow with one valid and one invalid import
85 workflowPath := filepath.Join(tempDir, "workflow.md")
86 workflowContent := `---
87on: push
88imports:
89 - valid.md
90 - missing.md
91---
92
93# Test Workflow
94`
95 if err := os.WriteFile(workflowPath, []byte(workflowContent), 0644); err != nil {
96 t.Fatalf("Failed to write workflow file: %v", err)
97 }
98
99 // Extract frontmatter
100 result, err := parser.ExtractFrontmatterFromContent(workflowContent)
101 if err != nil {
102 t.Fatalf("Failed to extract frontmatter: %v", err)
103 }
104
105 // Try to process imports with source information
106 _, err = parser.ProcessImportsFromFrontmatterWithSource(
107 result.Frontmatter,
108 tempDir,
109 nil,
110 workflowPath,
111 workflowContent,
112 )
113
114 // Should get a formatted error for the missing file
115 if err == nil {
116 t.Fatal("Expected error for missing import file, got nil")
117 }
118
119 errStr := err.Error()
120
121 // Check that error points to the correct import
122 if !strings.Contains(errStr, "missing.md") {
123 t.Errorf("Error should mention 'missing.md', got:\n%s", errStr)
124 }
125
126 // Check line number (should be line 5)

Callers

nothing calls this directly

Calls 5

TempDirFunction · 0.92
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected