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

Function TestFrontmatterLocationIntegration

pkg/parser/integration_test.go:12–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestFrontmatterLocationIntegration(t *testing.T) {
13 // Create a temporary file with frontmatter that has additional properties
14 tempFile := "/tmp/gh-aw/gh-aw/test_frontmatter_location.md"
15
16 // Ensure the directory exists
17 err := os.MkdirAll(filepath.Dir(tempFile), 0755)
18 if err != nil {
19 t.Fatalf("Failed to create temp directory: %v", err)
20 }
21
22 content := `---
23name: Test Workflow
24on: push
25permissions:
26 contents: read
27invalid_property: value
28another_bad_prop: bad_value
29engine: claude
30---
31
32This is a test workflow with invalid additional properties in frontmatter.
33`
34
35 err = os.WriteFile(tempFile, []byte(content), 0644)
36 if err != nil {
37 t.Fatalf("Failed to create temp file: %v", err)
38 }
39 defer os.Remove(tempFile)
40
41 // Create a schema that doesn't allow additional properties
42 schemaJSON := `{
43 "type": "object",
44 "properties": {
45 "name": {"type": "string"},
46 "on": {"type": ["string", "object"]},
47 "permissions": {"type": "object"},
48 "engine": {"type": "string"}
49 },
50 "additionalProperties": false
51 }`
52
53 // Parse frontmatter
54 frontmatterResult, err := ExtractFrontmatterFromContent(content)
55 if err != nil {
56 t.Fatalf("Failed to extract frontmatter: %v", err)
57 }
58
59 // Validate with location information
60 err = validateWithSchemaAndLocation(frontmatterResult.Frontmatter, schemaJSON, "test workflow", tempFile)
61
62 if err == nil {
63 t.Fatal("Expected validation error for additional properties, got nil")
64 }
65
66 errorMessage := err.Error()
67 t.Logf("Error message: %s", errorMessage)
68
69 // Verify the error points to the correct location

Callers

nothing calls this directly

Calls 4

ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected