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

Function TestHasMalformedYAML

internal/sheet/parse_test.go:99–112  ·  view source on GitHub ↗

TestHasMalformedYAML asserts that an error is returned when the frontmatter contains invalid YAML that cannot be unmarshalled

(t *testing.T)

Source from the content-addressed store, hash-verified

97// TestHasMalformedYAML asserts that an error is returned when the frontmatter
98// contains invalid YAML that cannot be unmarshalled
99func TestHasMalformedYAML(t *testing.T) {
100
101 // stub cheatsheet content with syntactically invalid YAML between the
102 // delimiters (a bare tab character followed by unquoted colon)
103 markdown := "---\n\t:\t:\n---\nBody text here"
104
105 // parse the frontmatter
106 _, _, err := parse(markdown)
107
108 // assert that an error was returned due to YAML unmarshal failure
109 if err == nil {
110 t.Error("failed to error on malformed YAML frontmatter")
111 }
112}

Callers

nothing calls this directly

Calls 1

parseFunction · 0.85

Tested by

no test coverage detected