MCPcopy Index your code
hub / github.com/cheat/cheat / TestHasInvalidFrontmatter

Function TestHasInvalidFrontmatter

internal/sheet/parse_test.go:75–95  ·  view source on GitHub ↗

TestHasInvalidFrontmatter asserts that markdown is properly parsed when it contains invalid frontmatter

(t *testing.T)

Source from the content-addressed store, hash-verified

73// TestHasInvalidFrontmatter asserts that markdown is properly parsed when it
74// contains invalid frontmatter
75func TestHasInvalidFrontmatter(t *testing.T) {
76
77 // stub our cheatsheet content (with invalid frontmatter)
78 markdown := `---
79syntax: go
80tags: [ test ]
81To foo the bar: baz`
82
83 // parse the frontmatter
84 _, text, err := parse(markdown)
85
86 // assert that an error was returned
87 if err == nil {
88 t.Error("failed to error on invalid frontmatter")
89 }
90
91 // assert that the "raw" markdown was returned
92 if text != markdown {
93 t.Errorf("failed to parse text: want: %s, got: %s", markdown, text)
94 }
95}
96
97// TestHasMalformedYAML asserts that an error is returned when the frontmatter
98// contains invalid YAML that cannot be unmarshalled

Callers

nothing calls this directly

Calls 1

parseFunction · 0.85

Tested by

no test coverage detected