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

Function TestImportFileNotFoundError

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

Source from the content-addressed store, hash-verified

13)
14
15func TestImportFileNotFoundError(t *testing.T) {
16 tempDir := testutil.TempDir(t, "import-error-*")
17
18 // Create a workflow with a missing import
19 workflowPath := filepath.Join(tempDir, "workflow.md")
20 workflowContent := `---
21on: push
22imports:
23 - nonexistent.md
24---
25
26# Test Workflow
27`
28 if err := os.WriteFile(workflowPath, []byte(workflowContent), 0644); err != nil {
29 t.Fatalf("Failed to write workflow file: %v", err)
30 }
31
32 // Extract frontmatter
33 result, err := parser.ExtractFrontmatterFromContent(workflowContent)
34 if err != nil {
35 t.Fatalf("Failed to extract frontmatter: %v", err)
36 }
37
38 // Try to process imports with source information
39 _, err = parser.ProcessImportsFromFrontmatterWithSource(
40 result.Frontmatter,
41 tempDir,
42 nil,
43 workflowPath,
44 workflowContent,
45 )
46
47 // Should get a formatted error
48 if err == nil {
49 t.Fatal("Expected error for missing import file, got nil")
50 }
51
52 errStr := err.Error()
53
54 // Check that error contains source location
55 wantContains := []string{
56 "workflow.md:4:", // Line number
57 "error:", // Error type
58 "import file not found", // Error message
59 "nonexistent.md", // Import path
60 }
61
62 for _, want := range wantContains {
63 if !strings.Contains(errStr, want) {
64 t.Errorf("Error missing expected string %q\nGot:\n%s", want, errStr)
65 }
66 }
67}
68
69func TestMultipleImportsWithError(t *testing.T) {
70 tempDir := testutil.TempDir(t, "import-error-*")

Callers

nothing calls this directly

Calls 5

TempDirFunction · 0.92
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected